for (String[] stu : nameList) { FiletargetDir=newFile(target, stu[2]); if (!targetDir.exists()) { targetDir.mkdirs(); } } int i; for (i = 0; i < nameList.size(); i++) { Stringid= nameList.get(i)[0]; Stringname= nameList.get(i)[1]; StringclassNo= nameList.get(i)[2];
if (!fileIdList.contains(id)) { noExistIdSet.add(id); } else { StringsrcPath= srcDir + id + ".jpg"; StringtargetPath= target + classNo + "/" + id + "_" + name + ".jpg"; copyFile(srcPath, targetPath); } } return noExistIdSet; }
for (String[] stu : nameList) { FiletargetDir=newFile(target, stu[2]); if (!targetDir.exists()) { targetDir.mkdirs(); } } int i; for (i = 0; i < nameList.size(); i++) { Stringid= nameList.get(i)[0]; Stringname= nameList.get(i)[1]; StringclassNo= nameList.get(i)[2];
if (!fileIdList.contains(id)) { noExistIdSet.add(id); } else { StringsrcPath= srcDir + id + ".jpg"; StringtargetPath= target + classNo + "/" + id + "_" + name + ".jpg"; copyFile(srcPath, targetPath); } } return noExistIdSet; }
/** * @param filename * @return * @throws FileNotFoundException */ public List<String> getValidFileIdList(String filename)throws FileNotFoundException { List<String> result = newArrayList<>(); Filefile=newFile(filename); File[] fileList = file.listFiles(); if (fileList == null) { thrownewFileNotFoundException(); } for (File fileEle : fileList) { Stringname= fileEle.getName(); if (name.matches("[0-9]{10}.jpg")) { result.add(name.substring(0, 10)); } } return result; }
/** * @param filename * @return * @throws IOException */ public List<String[]> getNameList(String filename) throws IOException { Stringline=""; Reader reader; List<String[]> result = newArrayList<>(); reader = newFileReader(filename); LineNumberReaderlineReader=newLineNumberReader(reader); while (true) { line = lineReader.readLine(); if (line == null) { break; } result.add(line.split("\t")); } return result; }
/** * 复制IO流 * * @param in * @param out * @throws IOException */ publicstaticvoidcopyIO(InputStream in, OutputStream out) throws IOException { byte[] buf = newbyte[CHUNK_SIZE]; /** * 从输入流读取内容并写入到另外一个流的典型方法 */ intlen= in.read(buf); while (len != -1) { out.write(buf, 0, len); len = in.read(buf); } }