How to input several csv files from a prticular folder and exporting them in another folder in JAVA?

I have written the code which lists the name of the csv files from a folder then takes input from a different folder to read subject-1.csv then after sorting them out exporting result-1.txt in Export folder then again taking another input as subject-2.csv from another folder, then sorting and exporting result-2.txt in the Export folder and I have one class called Student because all the csv files have same format.

But my task is to read all the files from a single folder then reading and sorting subject-1.csv then exporting like result-1.txt then writing in Export folder the same way for subject-2.csv and exporting result-2.txt.

All files must be read from a particular folder and exporting in another folder. Only two folder have to do all the tasks.

The main is below

public static void main(String[] args) throws IOException,    
InterruptedException { 

  String data = "UNSORTED"+":  " 
        + ""

  File directory = new File("conf/files");
  File[] listOfFiles = directory.listFiles();

  for (File file1 : listOfFiles) {

      System.out.println(" CSV file found  -------------->  " +     

readAllLinesFromFile("conf/subject-1.csv");// reading


readAllLinesFromFile1("conf/files/subject-2.csv");// reading


File file = new File("Export/result-1.txt");
  FileOutputStream fis = new FileOutputStream(file);
PrintStream out = new PrintStream(fis);
System.out.println("Sorting out successful");

 for(String aStudentString: aList){



 File file1 = new File("Export/result-2.txt");
   FileOutputStream fis1 = new FileOutputStream(file1);
 PrintStream out1 = new PrintStream(fis1);
 System.out.println("Sorting out successful");

  for(String aStudentString1: aList1){



ArrayList<Student> students = convertToStudents(aList);   
for(Student student : students){
    System.setOut(out );


ArrayList<Student> students1 = convertToStudents(aList1);   
for(Student student1 : students1){
    System.setOut(out1 );



At the moment I can do it by different folders and mentioning their names what to read and write.

My new idea is below but not getting the way out how to make it functioning.

File [] files = new File(path ).listFiles(new FileFilter() {
    public boolean accept(File path) {
        if(path .isFile()) {
 System.out.println("File name is  -------------->" + path.getName());   

            //Do something with a single file (reading and writing tested)
            //or just return true to put it in the list
            return true;
        return false;

Sample of csv files




I have been stuck for a long time, please help me out.