import java.text.SimpleDateFormat;
import java.util.Calendar;

import net.fckeditor.connector.ConnectorServlet;

import org.apache.commons.lang.StringUtils;

public class FileUtl {
	/**
	 * 文件重命名(带后缀)
	 * @param fileName
	 * @return
	 */
	public static String replaceFileName(String fileName) {

		StringBuilder builder = new StringBuilder();
		if (StringUtils.isNotEmpty(fileName)) {
			int index = fileName.lastIndexOf(".");
			if (index > 0) {
				SimpleDateFormat format = new SimpleDateFormat(
						"yyyyMMddHHmmssSSS");

				String suffix = fileName.substring(index);// 文件后缀名
				Calendar cal = Calendar.getInstance();

				builder.append(format.format(cal.getTime()));
				builder.append(suffix);
			}
		}
		return builder.toString();
	}

	/**
	 * 文件重命名(不带后缀)
	 * @param fileName
	 * @return
	 */
	public static String replaceName(String fileName) {

		StringBuilder builder = new StringBuilder();
		if (StringUtils.isNotEmpty(fileName)) {
			SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
			Calendar cal = Calendar.getInstance();
			builder.append(format.format(cal.getTime()));
		}
		return builder.toString();
	}
}
最近下载更多
好的好的  LV8 2022年7月4日
樊亚杨  LV1 2020年9月2日
a1060355600  LV5 2018年8月16日
沉默的羔羊  LV13 2017年1月1日
wzg356  LV18 2015年1月3日
AXIN  LV36 2014年1月20日
最近浏览更多
heqian  LV16 2023年1月10日
lsq54365  LV14 2022年9月8日
好的好的  LV8 2022年7月4日
sswert  LV2 2022年3月8日
z1433151083  LV9 2021年6月3日
笑香曼辰  LV3 2021年3月25日
jaonsang  LV25 2021年3月8日
whfuai  LV14 2021年2月1日
dongzhan  LV12 2020年12月22日
樊亚杨  LV1 2020年9月2日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友