Hello list

         I'm migrating from CGI-WIN to servlets and, noticed that the loop
below is not only slow but also, consumes a lot of CPU processor.

         Wonder if someone else could suggest something better.

         ThanXs in advance !

         Follows a part of the servlet code:


        response.setContentType("text/html");
        PrintWriter rw=response.getWriter();

        while (! FOut.exists() )
          {
            try
            {
              Thread.sleep(100);
            }
            catch(InterruptedException ex)
            {
            }
          }

        FileReader frout = new FileReader(FOut);
        BufferedReader brout = new BufferedReader(frout);

//***************************************************************************
//      This loop below :
//***************************************************************************
//        int c;
//        while ((c = brout.read()) != -1)
//          rw.print((char) c);
//***************************************************************************
//      This way is better, but not enough :
//***************************************************************************
        String line;
        while ((line = brout.readLine()) != null)
          rw.print(line + "\r\n");
//***************************************************************************

        rw.close();

        brout.close();

        FOut.delete();



                                Obrigado/Thanks a lot,

                                Jose Adriano Baltieri
                                Analista de Sistemas
                                CPD - CENTRO
                                UNIMEP - Universidade Metodista de Piracicaba
                                PIRACICABA - SP - BRASIL
                                Fone : 055 0 XX 19 430-1858 (english spoken)
                                Fax  : 055 0 XX 19 430-1898 (cx postal 42778)

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to