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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reading multiple txt files " Watch "Reading multiple txt files " New topic

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

Joined: Oct 13, 2005
Posts: 37884
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
Similar Threads
How to search a file???
Linefeed problem while scanning a line
How to count and scan the number of characters in a line?
question about Scanner and Arraylist
Write a program that merges two files containing alphabetized lists of student records into a single