截取文件路径组成新文件路径
File file = new File("c:/test");
File[] s = ListFileUtil.listFiles("c:/test");
for(File f:s){
String srcFilePath = f.getAbsolutePath(); //文件所在路径
String src = file.getAbsolutePath(); //根目录
String newpp = srcFilePath.substring(srcFilePath.indexOf(src)+src.length());//截取后相对路径
String newpath = "new path : e:"+newpp;
System.out.println(newpath);
}
浙公网安备 33010602011771号