Hi,
I need to copy a file into a different file after cutting off the last few lines based on a check.
The problem I am encountering is that the final file is shorter than the original and cutting off portions that should be there.
The original file is of length 779KB and the new file is only 768KB.
Here is the code.
any help will be appreciated.
BufferedReader bufIn = new BufferedReader(new FileReader(currFile)) ;
File outFile = new File("out.txt");
if(!outFile.exists()) {
outFile.createNewFile();
}
BufferedWriter bufOut = new BufferedWriter(new FileWriter(outFile)) ;
String lineByLine = bufIn.readLine();
while (lineByLine!=null){
lineByLine = bufIn.readLine();
bufOut.write(lineByLine+"\n");
if (lineByLine.startsWith("T837")){
break;
}//end if
}//end while