62,614
社区成员
发帖
与我相关
我的任务
分享
// 取source文件夹的绝对路径,取到为 E:\eclipse\workspace\tryBufferedReader\source
String sourceFilePath = new File("source").getAbsolutePath();
System.out.println(sourceFilePath);
String find = "E:\\eclipse";
String targetDir = "E:\\target";
sourceFilePath.replaceFirst(find, targetDir);
System.out.println(sourceFilePath);
String sourceFilePath = "E:\\eclipse\\123";
System.out.println(sourceFilePath);
String find = "E:\\\\eclipse";
String targetDir = "E:\\\\target";
sourceFilePath = sourceFilePath.replaceFirst(find, targetDir);
System.out.println(sourceFilePath);