• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Creating a new object if textfile changes

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have look on Collection interface, that should solve your problem
 
Marshal
Posts: 76873
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic