• Post Reply Bookmark Topic Watch Topic
  • New Topic

reading numbers & string from text file into vector  RSS feed

 
Melissa Lee
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to read the below textfile into a vector.
I have create a class Student, and then I’ve call the file reader to read in line, but then how do I make it read all names, then all numbers and all notes and put it in a vector.
I am stuck here, any hint most welcome.

Tex t file :
sally
175
notes on students
mark
180
notes on students
 
luc comeau
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well what i would do is make a buffered reader with the FileReader as its paramter.ie.
BufferedReader br= new BufferedReader(FileReader(filename));etc..
then do the read line, and loop while it is not null then for each string that is the read line value, just store it in a vector by using vector.add() method.It seems simple enough because u dont have to do any string tokenization...Maybe im misunderstanding where your geting lost?
hope that gets you a start maybe someone else has better idea?
-luc
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!