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

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

  

posted @ 2014-04-14 11:01  vance.  阅读(201)  评论(0编辑  收藏  举报