Smartupload Automatic Upload Package

Source: Internet
Author: User

A silent development learner

Generate the file name with the following code

 1 package info.haowei.util; 2 3 Import Java.text.SimpleDateFormat; 4 Import java.util.Date; 5 Import Java.util.Random;     6 7 public class Iptimestamp {8 9 private SimpleDateFormat SDF = null;11 private String IP = null;12 Public iptimestamp (String IP) {super (); This.ip = ip;18}19 publi  C Iptimestamp () {super ();}24-Public String Getiptimerand () {StringBuffer buf = new StringBuffer (), if (this.ip! = null) {s[] = this.ip.split ("\ \"); /based on IP, the number in the IP is extracted by a dot partition (int i = 0; i < s.length; i++) {Buf.append (This.addzero (S[i], 3) )///insufficient three-digit 32}33}34 buf.append (This.gettimestamp ()), random r = new random ();//again in Add three random numbers to the end (int i = 0; i < 3; i++) {PNs buf.append (r.nextint));}39 retur n buf.tostring ();}41 PrivaTe string Addzero (string str, int len) {stringbuffer s = new StringBuffer (); s.append (str);      (S.length () <len) {s.insert (0, 0);}49-s.tostring (); 51 }52 Gettimestamp () {//get timestamp THIS.SDF = new SimpleDateFormat ("Yyyymmddhhmmss SSS "); This.sdf.format return (New Date ());}58-Public String getDate () {this.sdf = NE W SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss. SSS "); This.sdf.format return (New Date ()); 62}63}

Smartupload Automatic Upload Package

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.