BufferedReader d
= new BufferedReader(new InputStreamReader(in));
String final=new String();
while(true)
{
String currentLine=d.readLine();
if(currentLine==null)
{
break;
}
final=final+currentLine+'\r\n';
}
StringTokenizer strTokenizer=new StringTokenizer (final,'\r\n');
BufferedWriter w
= new BufferedWriter(new OutputStreamWriter(out));
for(int i=1;i<(strTokenizer.countTokens()-2);i++)
{
w.write(strTokenizer.nextToken()+'\r\n');
}
nad...@parkerglobal.com (N.K.) wrote in message news:<2d4502eb.03070...@posting.google.com>...
presc...@ftml.net (Sam Pinkerton) wrote in message news:<119cfa8d.03071...@posting.google.com>...
> Use java.io.RandomAccessFile. Search backward from the end of the
> file until you've located the end of the line preceding the last line.
> Then use the setLength() method to truncate the file after that
> character.
>
> It will be most efficient to read a chunk not too large but large
> enough to almost certainly fully contain the last line. Then search
> within the buffer. That avoids the overhead of repeatedly seeking and
> reading a single byte.
>
> You may need to consider what to do if the last line in the file does
> not end with a proper line end (e.g., the file might simply stop with
> no line termination). Whether the file is normal ASCII (ISO-8859) or
> something else (e.g., unicode or, worse, one of the UTF variants) may
> complicate things. Also, the second or only character of the line
> separator is not necessarily \n. See the system property
> line.separator. But if you know your environment you can be lazy and
> just look for the \n (or \r if on a Mac).
>
> nad...@parkerglobal.com (N.K.) wrote in message news:<2d4502eb.03070...@posting.google.com>...