You can use the RandomAccessFile class to find the end of a file, read it, and then trim the file with setLength().
Update: Here is the code:
File target = new File("/path/to/file");
RandomAccessFile file = new RandomAccessFile(target,"rwd");
file.seek(target.length()-1);
char c = file.readChar();
if(c == '|')
{
file.setLength(target.length()-1);
}
. , ..
8- , target.length()-1.