Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying records on screen

 
Sharon Hour
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Not sure if i posting this in correct forum.

I am trying to output all records on a file to a screen but cannot understand what structure screen should have, ie if i want to put each record into particular text fields, i have no way of knowing how many rows of text fields i need.

I am only learning java and doing application as way of learning it. Could someone point me in the right direction.

Hope above makes sense.

Thanks,
Sharon
 
willem jacobus odendaal
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
alo sharon
i am not clear on what exactly you want to do, but i sugest reading the file line by line into a Vector and then you can get the size of the Vector and you'll know how many TextFields you'll need.

This might help:

Vector lines=new Vector();
File jobFile = new File(path);
try {
FileReader fr = new FileReader(jobFile);
BufferedReader br = new BufferedReader(fr);
try {
for(int i=0;i<100;i++){//however many lines will be needed
String line = br.readLine();
if(line!=null){
lines.addElement(line );
}
}
}
catch (IOException ex1) {
}
}
catch (FileNotFoundException ex) {
}

cheers!
 
Sharon Hour
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never thought of a Vector - thanks for your help!
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am only learning java and doing application as way of learning it. Could someone point me in the right direction.

Here is a list of free on-line Java tutorials and books that I have found useful:
  • Sun's Java Tutorial
  • Introduction to Computer Science using Java by Bradley Kjell
  • Introduction to Programming Using Java by David J. Eck
  • Dick Baldwin's Java Programming Tutorials
  • Interactive Programming In Java by Lynn Andrea Stein
  • Bruce Eckel's Thinking In Java
  • JavaRanch's own Campfire Stories
  • Allen B. Downey's How To Think Like A Computer Scientist
  •  
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic