• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating a new object if textfile changes  RSS feed

 
Emile Fraser
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

Can you guys please advise if this is possible or an other way to accompish the following:

I have a text file with certain fields for example
Student Number Student Name Student Semester Average
KCH0001 Emile 66
KCH0002 Roan 70
KCH0003 Zvone 22

I want to create an object in a Class called Student that has 2 variables for a method called stdName and stdMark.

I read the new student numbers into a variable called stdNum and want to create an object with the current value of the variable of stdNum like follows:
Student "KCH0001" = new Student(); --> I know this doesn't compile I jsut want to show what I want to do.

So basically I want to create a new object every time the a new student is added to the text file?
 
Peter Miklosko
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have look on Collection interface, that should solve your problem
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

As previously hinted, you are probably going about this backwards. To find whether the text file has changed, you would require a thread with an infinite loop which checks the file for its most recent update, then reads the file to count how many new lines it has. That is probably an inefficient way to program.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!