/** * A simple ReadFile Class where It will take the input as a redirection from any csv file * so i won't need to tie it down to one particular file, i can just process any file * with a redirection. * * @author Freeman Lo * @version 0.0.1 Build 1 April 1, 2014. * Limitations - next time, i will do FILE I/O through as an argument from main instead of file redirection. * Sadly enough, i seem to always do file input with all my java code with file redirection * Python code on the other hand, i have never done file redirection but i've done hardcode open file and from arguments * i need to reverse the order sometimes. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class ReadFile { public ArrayList readFile() { List fileContent = new ArrayList(); String line; BufferedReader br=null; br = new BufferedReader( new InputStreamReader(System.in) ); try { while ( (line=br.readLine()) !=null ) { fileContent.add(line); } } // end try catch (IOException e) { e.printStackTrace(); } // end catch // reversing the list Collections.reverse(fileContent); // removing the text fileContent.remove(fileContent.size() - 1); // return file content after reversing the file and removing the texts return (ArrayList) fileContent; } // End public } // end class