上传文件自命名规则
public class IPTimeStamp {
private SimpleDateFormat sdf = null;
private String ip = null;
public IPTimeStamp(){
}
public IPTimeStamp(String ip){
this.ip = ip;
}
public String getIPTimeRand(){
StringBuffer buf = new StringBuffer();
if(this.ip !=null){
String s[] = this.ip.split("\\.");
for(int i=0;
i buf.append(this.addZero(s[i],3));
}
}
buf.append(this.getTimeStamp());
Random r = new Random();
for(int i=0;
i<3;
i++){
buf.append(r.nextInt(10));
}
return buf.toString();
}
public String getDate(){
this.sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
return this.sdf.format(new Date());
}
public String getTimeStamp(){
this.sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
return this.sdf.format(new Date());
}
public String addZero(String str,int len){
StringBuffer s = new StringBuffer();
s.append(str);
while(s.length()
}
return s.toString();
}
public static void main(String [] args){
System.out.println(new IPTimeStamp("192.168.1.1").getIPTimeRand());
}
}
推荐阅读
- 宽容谁
- 尽力
- 讲述,美丽聪明的海欧!
- 夜游宫|夜游宫 心语
- 画画吗()
- 艾略特的交易法则“遵循自然规律”
- 猎杀IP
- 陇上秋二|陇上秋二 罗敷媚
- 图书集合完毕
- 牛人进化+|牛人进化+ 按自己的意愿过一生