title: "Premature end of file" while parsing xml from the net
body: <p>When I try to parse XML file from the net in this way:</p>
  
  <pre><code>URL url = new URL("http://www.nbp.pl/kursy/xml/a074z120416.xml");
  URLConnection uc = url.openConnection();
  saxParser.parse(uc.getInputStream(), handler);
  </code></pre>
  
  <p>Premature end of file Exception is throwing.</p>
  
  <p>Stack trace:</p>
  
  <pre><code>org.xml.sax.SAXParseException: Premature end of file.
  at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
  at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
  at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
  at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
  at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
  at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
  at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
  at javax.xml.parsers.SAXParser.parse(Unknown Source)
  at javax.xml.parsers.SAXParser.parse(Unknown Source)
  at com.pmajcher.xmltest.ReadXMLFile.main(ReadXMLFile.java:142)
  </code></pre>
  
  <p>But when I first save that xml to local file, and then try to parse it, everything is ok.</p>
  
  <pre><code>URL url = new URL("http://www.nbp.pl/kursy/xml/a074z120416.xml");
  URLConnection uc = url.openConnection();
  InputStreamReader input = new InputStreamReader(uc.getInputStream());
  BufferedReader in = new BufferedReader(input);
  File file = new File("temp.xml");
  
  if(!file.exists()){
      file.createNewFile();
  }
  
  PrintWriter out = new PrintWriter(file);
  String inputLine;
  
  while ((inputLine = in.readLine()) != null) {
      out.print(inputLine);
  }
  out.close();
  saxParser.parse("temp.xml", handler);
  </code></pre>
  
  <p>What's wrong with the way I try to parse xml from the net?</p>