SmartUpload使用和简介
2015-07-24 10:51
232 查看
SmartUpload使用和简介
用以下代码生成文件名即可
用以下代码生成文件名即可
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 10 private SimpleDateFormat sdf = null; 11 private String ip = null; 12 13 14 public IPTimeStamp(String ip) { 15 super(); 16 17 this.ip = ip; 18 } 19 20 21 public IPTimeStamp() { 22 super(); 23 } 24 25 26 public String getIPTimeRand(){ 27 StringBuffer buf = new StringBuffer(); 28 if(this.ip != null){ 29 String s[] = this.ip.split("\\.");//根据ip以点分割将IP中的数字提取 30 for(int i = 0 ; i < s.length; i++){ 31 buf.append(this.addZero(s[i], 3));//不够三位数的补零 32 } 33 } 34 buf.append(this.getTimeStamp()); 35 Random r = new Random();//再在结尾加上三个随机数 36 for(int i = 0 ; i < 3 ; i++ ){ 37 buf.append(r.nextInt(10)); 38 } 39 return buf.toString(); 40 } 41 42 private String addZero(String str, int len){ 43 44 StringBuffer s = new StringBuffer(); 45 s.append(str); 46 while(s.length()<len){ 47 s.insert(0, 0); 48 } 49 50 return s.toString(); 51 } 52 53 54 private String getTimeStamp(){//获取时间戳 55 this.sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); 56 return this.sdf.format(new Date()); 57 } 58 59 public String getDate(){ 60 this.sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); 61 return this.sdf.format(new Date()); 62 } 63 }
相关文章推荐
- 基于servlet+smartUpload的文件上传
- 文件下载上传
- Java文件下载和上传源代码
- 上传头像的例子—smartUpload的使用
- JSP表单含有上传功能时出现不能获取表单的其他内容
- 使用smartupload组件上传图片(jsp+servlet)
- 文件上传与下载
- smartUpload控件使用
- 文件上传--Smartupload上传组件【上】
- 文件上传--Smartupload上传组件【中】
- 文件上传--Smartupload上传组件【下】
- 学习SmartUpload组件时,出现文件不能保存的异常
- SmartUpload实现文件的上传与下载
- smartupload实现文件上传时获取表单数据
- 使用jspsmartupload完成简单的文件上传系统
- smartupload下载
- smartupload 的简单使用(上传)
- SmartUpload 的乱码处理
- 使用smartUpload实现文件的上传与下载
- 在handler中使用SmartUpload上传组件失败