I'm not to sure how to move the pointer on the file your working with. For example in the following code: the 2 print statements (in blue) read lines 1 - 3. but the writting in orange continues reading the file. How do i move the pointer up to line 1 again to that the writting in orange does not continue from where the writting in blue left off ?
BufferedReader input2 = new BufferedReader (new FileReader ("C:\\output.txt"));
//int intNumberofLines = 0; // default 0 because there is always 1 line to read
// first we get all the data so that it isn't written over
intNumberofLines = Integer.valueOf (input2.readLine ()).intValue ();
c.print(input2.readLine());
c.print(input2.readLine());
//c.print ("2nd line is: " + Integer.valueOf (input2.readLine ()).intValue ());
//c.print ("3rd line is: " + Integer.valueOf (input2.readLine ()).intValue ());
//c.print ("number of lines is" + intNumberofLines);
// String inputString [] = new String [intNumberofLines]; // array large enough to hold all text data
for (int y = 0 ; y < (intNumberofLines - 1) ; y++) // +1 because we've already read the int for line 1.
{
inputString [y] = input2.readLine (); // because array starts at 0 not 1.
c.print ("String is: " + inputString [y]);
}
inputStringFinal = new String [intNumberofLines + 1]; // +1 because the tempLicense is added to the array.
blnStringDeclared = true; // so it can be used when (inputAns = 1)
// cloning array and adding the final License
for (int i = 0 ; i < intNumberofLines ; i++) // cloning the array
{
inputStringFinal [i] = tempLicense;
}
inputStringFinal [intNumberofLines] = tempLicense; // the last boundary is used for the license just created
c.print ("first line 1: " + input2.readLine());
c.print ("second line 2: " + input2.readLine());
c.print ("third line 3: " + input2.readLine());