Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #9045

Re: org.xml.sax.SAXParseException: Premature end of file

From Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: org.xml.sax.SAXParseException: Premature end of file
Date 2011-10-20 20:15 +0200
Organization A noiseless patient Spider
Message-ID <j7poi6$2c0$1@dont-email.me> (permalink)
References <22aef44f-90f0-4fe4-a20e-64f336e4c1b3@g25g2000yqh.googlegroups.com>

Show all headers | View raw


On 20/10/2011 17:41, laredotornado allegedly wrote:
> 		xml = xml.trim();
> 		final InputStream inputStream = new
> ByteArrayInputStream(xml.getBytes());
> 		final DocumentBuilderFactory dbf =
> DocumentBuilderFactory.newInstance();
> 		final DocumentBuilder db = dbf.newDocumentBuilder();
> 		final Document doc = db.parse(xmlInputStream);

> 		final InputStream inputStream = new
> ByteArrayInputStream(xml.getBytes());

Don't do this.

Instead:

db.parse( new InputSource( new StringReader(xml) ) );

-- 
DF.
Determinism trumps correctness.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar


Thread

org.xml.sax.SAXParseException: Premature end of file laredotornado <laredotornado@zipmail.com> - 2011-10-20 08:41 -0700
  Re: org.xml.sax.SAXParseException: Premature end of file markspace <-@.> - 2011-10-20 10:04 -0700
    Re: org.xml.sax.SAXParseException: Premature end of file laredotornado <laredotornado@zipmail.com> - 2011-10-20 10:59 -0700
      Re: org.xml.sax.SAXParseException: Premature end of file Lew <lewbloch@gmail.com> - 2011-10-20 14:06 -0700
  Re: org.xml.sax.SAXParseException: Premature end of file Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2011-10-20 20:15 +0200

csiph-web