We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
BufferedReader (Read 231 times)
BufferedReader
Feb 20th, 2008, 3:55pm
 
I have 2 BufferedReader, cycling through a file just as i,j do in this example:
 for (int i=0; i<num; i++)
   {for (int j=i; j<num; j++)
    {...}
   }

Code:
 try {
BufferedReader reader1 = new BufferedReader (new FileReader (fname)) ;
BufferedReader reader2 = new BufferedReader (new FileReader (fname)) ;
while (reader1.ready()) {
// >>> here reader2 should be where is reader1 ???
p=Integer.parseInt(reader1.readLine());
while (reader2.ready()) {
q=Integer.parseInt(reader2.readLine());
println(p+q);
}
}
}
How can I reset reader2 to point to where reader1 is (at the start of each loop) ?
Page Index Toggle Pages: 1