截取文件路径组成新文件路径

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);
		}

  

原文地址:https://www.cnblogs.com/baby-bear/p/3663568.html