you started off with two pieces of code, one class that read a file, one that wrote a file.
start with the one that reads the file, and try putting that single part of the functionallity in one separate method, that stores every single line you read in an ArrayList and return that list later on.
here's something to get you started:
public static ArrayList<String> getFileContents(String fileName)
throws IOException{
ArrayList<String> contents = new ArrayList<String>();
// here you add your code, based on the code in your first main method
return contents;
}
whether this method is to be static or not, depends whether you will instantiate this class or not.
on a method like this, you can throw an Exception, since you still can catch it in the main method, but the main method is the very last place where you can catch and gracefully handle any exception.