Java - DocumentBuilder closing Socket connection -
I have a problem with a socket connection which is closing too fast. I was told that I need to temporarily load the data from socket and parse it. Here is my code:
listen to server socket = new server socket (this.port); Socket server; While (i & lt; this.maxConnections) {server = listen.accept (); ProcessRequest (server); I ++; } process request
throws secure IOException process request (socket server) {ProcessXML response = new processcode (server.getInputStream ()); New PrintWriter (server.getOutputStream (), true) .println ("feedback text"); } processXML
public processing XML (InputStream) {DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance (); Factory.setValidating (wrong); Factory.setNamespaceAware (wrong); Document doc = factory.nudecutterbilder (). Pars (new input source (s)); ....} error
[fatal error]: 2: 1: premiere of the file. Org.xml.sax.SAXParseException: Premature End of File Com.sun.org.apache.xerces.internal.parsers.DOMParser.parse at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse (unknown source) at ProcessXML. & Lt; Init & gt; The bank on the bank start.man (bank start.java: 6) The bank on the list (Bank.Java) Process Requests (Bank of Junk) (ProsexXML.Java 22) I now store the contents of server.GetInputStream () in a file I can supply it to DocumentBuilder , but I think that's a bad solution, how can I store content in some temporary storage and also that .parse ( ) to be able to supply without closing the socket?
I think the solution that you are using, requires that the data be created Be available on time. You will need to use the Stream Parser to get a STAX implementation and you should be able to do this
Comments
Post a Comment