This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to read in 2 input .txt files? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to read in 2 input .txt files?" Watch "How to read in 2 input .txt files?" New topic

How to read in 2 input .txt files?

Madysen Rayne

Joined: Feb 03, 2004
Posts: 11
Hello all
I have my program written and works well. I can get it to execute fine when i have this in my code:

What i want to do though in the DOS window is to be able to type
" java MergedSortedLists minors.txt majors.txt " so that i can test my code on any files without having to go into the code and manually change it each time. and this is what i come up with so far:
chi Lin
Ranch Hand

Joined: Aug 24, 2001
Posts: 348
one quick note below,

public class MergedSortedLists
public static void main(String [] args) throws IOException
List theList = new LinkedList();
String fileName = args[0];
String fileName2 = args[0]; // you mean args[1] here ?
File inFile = new File(fileName );
File inFile2 = new File(fileName2 );
BufferedReader fileInput = new BufferedReader( new FileReader(inFile));
BufferedReader fileInput2 = new BufferedReader( new FileReader(inFile2));

String oneLine = fileInput.readLine();//reads in first line of 1st record
PersonRecord theRecord = new PersonRecord(oneLine);
Madysen Rayne

Joined: Feb 03, 2004
Posts: 11
rawr! it worked
I didn't realize that I needed a 1 in there, which now makes sense... no wonder it was just reading in the same file twice...!
Have you checked out Aspose?
subject: How to read in 2 input .txt files?
It's not a secret anymore!