Skip to main content
added 77 characters in body
Source Link

You can put the file path to argument and create a list with all the filepaths and not put it the list manually. Then use a for loop and a reader. Example for txt files:

public static void main(String[] args) throws IOException{ File[] files = new File(args[0].replace("\\", "\\\\")).listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".txt"); } });  ArrayList<String> filedir = new ArrayList<String>();  String FILE_TEST = null;  for (i=0; i<files.length; i++){   filedir.add(files[i].toString());   CSV_FILE_TEST=filedir.get(i)    try(Reader testreader = Files.newBufferedReader(Paths.get(FILE_TEST)); ){ //write your stuff }}} 

You can put the file path to argument and create a list with all the filepaths and not put it the list manually. Then use a for loop and a reader. Example for txt files:

File[] files = new File(args[0].replace("\\", "\\\\")).listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".txt"); } }); ArrayList<String> filedir = new ArrayList<String>(); String FILE_TEST = null; for (i=0; i<files.length; i++){ filedir.add(files[i].toString()); CSV_FILE_TEST=filedir.get(i)    try(Reader testreader = Files.newBufferedReader(Paths.get(FILE_TEST)); ){ //write your stuff } 

You can put the file path to argument and create a list with all the filepaths and not put it the list manually. Then use a for loop and a reader. Example for txt files:

public static void main(String[] args) throws IOException{ File[] files = new File(args[0].replace("\\", "\\\\")).listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".txt"); } });  ArrayList<String> filedir = new ArrayList<String>();  String FILE_TEST = null;  for (i=0; i<files.length; i++){   filedir.add(files[i].toString());   CSV_FILE_TEST=filedir.get(i) try(Reader testreader = Files.newBufferedReader(Paths.get(FILE_TEST)); ){ //write your stuff }}} 
Source Link

You can put the file path to argument and create a list with all the filepaths and not put it the list manually. Then use a for loop and a reader. Example for txt files:

File[] files = new File(args[0].replace("\\", "\\\\")).listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".txt"); } }); ArrayList<String> filedir = new ArrayList<String>(); String FILE_TEST = null; for (i=0; i<files.length; i++){ filedir.add(files[i].toString()); CSV_FILE_TEST=filedir.get(i) try(Reader testreader = Files.newBufferedReader(Paths.get(FILE_TEST)); ){ //write your stuff }