public static void main(String[] args) {
String df = "/udd/itnms/file/123dd.dd.pdf";
System.out.println(changeFileType(df));
Properties d = new Properties();
System.out.println(d.getProperty("key"));
String ttt = "ff_d.22.2.txt";
System.out.println(ttt.matches("^\\w+(\\.\\w+)*$"));
System.out.println(ttt.getBytes().length);
System.out.println(ttt.length());
System.out.println(changeChar(ttt));
}
private static String changeFileType(String fileName) {
int index = fileName.lastIndexOf("/");
String signFileName = fileName.substring(index + 1);
int indexType = signFileName.lastIndexOf(".");
String addFileType = signFileName.substring(indexType + 1);
if (addFileType.toLowerCase().equals("pdf")) {
return fileName.substring(0, index + 1)
+ signFileName.substring(0, indexType + 1) + "tif";
}
return null;
}
private static String changeChar(String oldFileName) {
String changeName = oldFileName;
int index = oldFileName.lastIndexOf("\\");
String signFileName = oldFileName.substring(index + 1);
int indexType = signFileName.lastIndexOf(".");
String addFileType = signFileName.substring(indexType);
String fileName = signFileName.substring(0, indexType);
if (!fileName.matches("^\\w+(\\.\\w+)?$")) {
fileName = getNowDate() + "_" + "01";
return oldFileName.substring(0, index + 1)
+ fileName + addFileType;
}
return changeName;
}
/*
*
*/
private static String getNowDate() {
//
String nowDate = "";
Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
try {
//
java.text.SimpleDateFormat simpleDateFormat =
new java.text.SimpleDateFormat("yyyyMMddHHmmssSSS");
nowDate = simpleDateFormat.format(calendar.getTime());
} catch (Exception e) {
return "";
}
return nowDate;
}
System.out.println(Thread.currentThread().getContextClassLoader()
.getResource(""));
System.out.println(TestPath.class.getClassLoader().getResource(""));
System.out.println(ClassLoader.getSystemResource(""));
System.out.println(TestPath.class.getResource(""));
System.out.println(TestPath.class.getResource("/"));
System.out.println(new File("").getAbsolutePath());
System.out.println(System.getProperty("user.dir"));
分享到:
相关推荐
使用 VBA Excel 快速批量修改文件名 1、点击“生成文件名“按钮, 会在 "原文件名"列(A列)生成文件对应的文件名。 2、在"修改后文件名"列(B列)中输入想要修改后的文件名。 3、点击“重命名文件”后即可。 注:...
批量修改文件名 批量修改文件名批量修改文件名批量修改文件名批量修改文件名批量修改文件名批量修改文件名批量修改文件名批量修改文件名批量修改文件名批量修改文件名批量修改文件名批量修改文件名批量修改文件名...
进入指定目录下,获取指定类型文件名,并可以对文件名进行修改,c++代码
Net 是开源的,源代码请自行反编译: 该程序选择需要被修改文件名的文件夹路经,并对该文件夹下的所有文件修改名字,最后在该文件夹路经下新建文件夹存储修改好名字的文件;
用于批量修改文件名,对文件名批量替换或删除字符。 使用说明: 下载后,建议新建一个单独的文件夹,将下载后的.bat文件放入,然后把要重命名的文件复制到和.bat文件同级目录下,点击.bat文件运行,根据提示,输入...
一款非常强大的批量更改文件名软件,可以批量修改文件名,支持各种位置更改,以及更改后缀名等等功能,对于需要批量修改文件名来说,非常方便。
C# 开发的winform 形式的批量修改文件名
批量修改文件名,缩短长文件名,匹配字符删除指定字符串或修改,或指定字符区间删除字符串或修改
用Java编写一个复制程序,并更改文件名
VBS 批量修改文件名 VBS 批量修改文件名 VBS 批量修改文件名
VB做的批量修改文件名 VB做的批量修改文件名 VB做的批量修改文件名
文件名修改工具功能特色如下: 1、支持多种文件名批量的修改 。 2、可以整批量一次性修改目录下的文件名。 3、可以自由选择目录下多个文件进行批量修改文件名。 4、文件创建日期可以知道文件名的操作时间;流水号,...
pb实现批量更改文件名
运用Python按照要求批量修改文件名
批量更改文件名 批量更改文件名 替换文件名 批量智能命名文件
一款可以批量修改文件名的软件,
缤纷批量修改文件名功能: 批量删除文件名中的指定字符,或从文件名中指定位置删除n个字符 批量替换文件名中的字符 批量在文件名前添加字符,或在文件名后添加字符 批量给文件名编号,序号位置完全可自定义,同时...
c#写的批量修改文件名,可在文件名前添加内容,可替换文件名中的内容,可改后缀等。
批量修改文件名(附加C#源码)