aspose file tools*
The moose likes Beginning Java and the fly likes Reading multiple txt files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reading multiple txt files " Watch "Reading multiple txt files " New topic
Author

Reading multiple txt files

P Derlyuk
Ranch Hand

Joined: Feb 17, 2013
Posts: 33
I have a program where it is supposed to take a keyboard entry(userName) for a name. Then it searches for that name in two text files. One text file for the meaning(meaning.txt), and another for its popularity(names.txt). Then i have to print the line from each text file. When i type in a name (eg. Paul) that is in both text files, it says "Paul was not found." It should output its popularity and meaning. I attached what i did after main. Is there easier/simpler ways to read from multiple text files??



Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Why have you got so much code in the main method? Why are all your methods static?
What order are the names in the two files? How do you know you will find the same name in the same location in both?
Why are you using nextLine and next together? Who told you nextLine returns the next line?
P Derlyuk
Ranch Hand

Joined: Feb 17, 2013
Posts: 33
O, sorry i forgot to remove this post. I figured it out already. I made a separate method that searches the text files i send it and returns the line i need. Thanks anyways!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading multiple txt files