日期:2014-05-17 浏览次数:20656 次
public class FileRename {
public String getNewFileName(String originalFileName) {
StringBuffer newFileName = new StringBuffer();
if (null != originalFileName && !"".equals(originalFileName)) {
int port = originalFileName.lastIndexOf(".");
String type = "";
String fileName = "";
if (port != -1) {
type = originalFileName.substring(port + 1);
fileName = originalFileName.substring(0, port);
} else {
fileName = originalFileName;
}
JsonDateValueProcessor jdvp = new JsonDateValueProcessor();
JsonConfig jc = new JsonConfig();
StringBuffer suffix = new StringBuffer("_");
suffix.append(jdvp.processArrayValue(new Date(), jc));
suffix.append("_");
suffix.append(new Random().nextInt(100));
newFileName.append(fileName);
newFileName.append(suffix);
newFileName.append(".");
newFileName.append(type);