Help! Arrghh! This should be so simple.
I 'm trying to compare two files in several iterations.
The first file needs to be read by characters.
The second file should be read by lines.
The second file will have to be cycled through several times.
First Case (simplified code shown below):
I read in the second file and store in BufferedReader.
I mark file so I can go back to the top for another iteration.
I always get "java.io.IOException: Mark invalid"
How do I make this work!?
Second Case
So I try to Open/Process/Close...Open/Process/Close...
Still no go. The second file reads the first time.
It does not read the second time.
What am I missing?!?
Please Help!
mlg
/**/
public void methodIoa() {
String f1 = "D:\\file1.txt";
String f2 = "D:\\file2.txt";
String st1 = "", st2 = ""; int ctt = 0;
try {
FileReader fr1 = new FileReader(f1);
BufferedReader br1 = new BufferedReader(fr1);
FileReader fr2 = new FileReader(f2);
BufferedReader br2 = new BufferedReader(fr2);
//
while (!st1.equals("-1")) {
st1 = new Integer(br1.read()).toString();
System.out.println("\tst1:\t" + st1);
//*********************
if (ctt == 0) { br2.mark(1); } else { ctt++; }
while (st2 != null)
{
st2 = br2.readLine();
System.out.println("\tst2:\t" + st2);
}
br2.reset();
//*********************
}
br2.close(); fr2.close(); br1.close(); fr1.close();
System.out.println("Done");
}
catch (IOException e) { System.out.print(e); }
}