File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Read Line From file

 
Roger Fed
Ranch Hand
Posts: 82
Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I've used text files to store data about students
each line consists of student name, SSN, and score
This is the problem:Given SSN, search into the file and if you find matching read the current line from beginning to display such output
John F Smith:50.5
I've developed this class
but when the matching occur i cannot read the the current line from beginning
Can you help me in this???
thanks.
 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would read the file line by line rather than use a Scanner. Look for the match in each line, and if you find one, you already have the line in a String variable. Also, you don't waste time trying to match an SSN with the other tokens, which may be names or scores.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic