• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading multiple txt files

 
P Derlyuk
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48382
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic