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