commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Durham <ddur...@vailsys.com>
Subject [digester] multiple parses from one inputstream
Date Tue, 23 May 2006 23:12:32 GMT
Hi all,

I'd like to use Digester to parse multiple XML messsages being passed 
from a server to a client.  The parse method hangs until I close the 
server output stream.

Anyway to signal to Digester.parse(InputStream) that it should return 
without having reached the end of an inputstream?  Or do I have chose a 
different parse method?

Basically, I'd like to do something like this in the client:

   ..
     socket = new Socket("localhost", port);

     out = new PrintWriter(socket.getOutputStream(), true);
     in = new BufferedReader(new InputStreamReader(socket.getInputStream());

     String inputLine = null;
     while ((inputLine = stdIn.readLine()) != null) {
       System.out.println("From user: " + inputLine);
       if (inputLine.equals("Bye.")) {
         out.println("Bye.");
         break;
       }
       Digester digester = new Digester();
       digester.setValidating( false );

       digester.addObjectCreate( "test", DigesterTest.class );
       digester.addBeanPropertySetter("test/property", "property");

       DigesterTest test = null;

       try {
          test = (DigesterTest)digester.parse(in);
       } catch (IOException e) {
          e.printStackTrace(System.out);
       } catch (SAXException e) {
          e.printStackTrace(System.out);
       }

       System.out.println(test.getProperty());
       out.println("ready");
     }

     out.close();
     in.close();
     stdIn.close();
     socket.close();


Again, the client hangs on digester.parse until server closes output 
stream.  Thanks,

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message