quick reference
read
public static List<String> getAllTxtFiles(String dirLocation){
File f = new File(dirLocation);
if(!f.isDirectory() && f.getName().endsWith(".txt")){
fileList.add(f.getAbsolutePath());
}else if(f.isDirectory()){
File[] childFiles = f.listFiles();
for(File tf : childFiles){
getAllTxtFiles(tf.getAbsolutePath());
}
}
return fileList;
}
write
private static void writeToFile(String tolocation2) throws IOException {
File f = new File(tolocation2);
if(!f.isFile()) return;
FileWriter fw = new FileWriter(f, false);
for(String s : batch){
fw.write(s+"\n");
}
fw.close();
}