Reading a file that is being append too
From: Jorge Torres (jorge.torres_at_instinet.com)
Date: 11/26/03
- Next message: kevinc: "Re: Reading a file that is being append too"
- Previous message: DaiIchi: "Re: Problem with RMI in Linux"
- Next in thread: kevinc: "Re: Reading a file that is being append too"
- Reply: kevinc: "Re: Reading a file that is being append too"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Nov 2003 07:57:46 -0800
I have an applet application that reads a file located at the server.
Once I have establish the connection, I'm able read the contents of
the file with out any problems, until I have reached the end of the
file. Any new data that has been added to the file while the applet is
running I'm unable to read.
If I restart the applet again I can then see the data that was added.
Can someone please help me with this problem?
Thanks in advance!
Here is my code...
public void readFile(){
( new Thread() {
public void run() {
String line;
URL url = null;
try {
url = new URL( getCodeBase(), FileToRead );
}
catch( MalformedURLException e ) {
System.out.println( "Malformed URL " );
stop();
}
try {
InputStream in = url.openStream();
BufferedReader dis = new BufferedReader( new
InputStreamReader( in ) );
buf = new StringBuffer();
while( true ) {
while( ( line = dis.readLine() ) != null ) {
buf.append( line + "\n" );
}
// Load the file into the TextArea.
ta.append( buf.toString() );
Thread.currentThread().sleep( 5000 );
}
}
catch( IOException e ) {}
catch( InterruptedException ex ) {
System.out.println( "InterruptedException!" );
}
}
} ).start();
}
- Next message: kevinc: "Re: Reading a file that is being append too"
- Previous message: DaiIchi: "Re: Problem with RMI in Linux"
- Next in thread: kevinc: "Re: Reading a file that is being append too"
- Reply: kevinc: "Re: Reading a file that is being append too"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|