Reading a file that is being append too

From: Jorge Torres (jorge.torres_at_instinet.com)
Date: 11/26/03


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();
  }



Relevant Pages

  • Re: JDBC Applets - MS Access
    ... > I am working on a Applet at the moment which must be able to access ... > I need to be able to setup a jdbc connection to an Access database. ... JDataConnect also uses a server side JDBC server. ...
    (comp.lang.java.databases)
  • Re: IIS 6 & Server Permisions
    ... I am running a server side applett. ... link where I can find the correct changes to make in IIS6. ... is this Java application running on the Web Server or the Web Browser. ... where is the Applet trying to store the hit counters? ...
    (microsoft.public.inetserver.iis)
  • Applet Hangs when submitting data to servlet
    ... on our web server. ... applet that demonstrates the problem. ... private JButton theSubmitButton_, theClearButton_; ... public void actionPerformed ...
    (comp.lang.java.programmer)
  • Re: Thread info
    ... > I have an applet which automatically connects to my application server ... > as the applet closes it kills the connection with the application ... Or are you trying to reuse the server's thread so that it ...
    (comp.lang.java.programmer)
  • Re: Applet Hangs when submitting data to servlet
    ... on our web server. ... applet that demonstrates the problem. ... private JButton theSubmitButton_, theClearButton_; ... public void actionPerformed ...
    (comp.lang.java.programmer)