Reading http file on url
        Posted  
        
            by 
                Nkunzis
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Nkunzis
        
        
        
        Published on 2012-11-22T16:52:39Z
        Indexed on 
            2012/11/22
            16:59 UTC
        
        
        Read the original article
        Hit count: 231
        
I am trying to read an xml file on an http url. "Unexpected end of file from server" keeps on coming . the page is password protected, I would like to know if I am properly giving in my url authentication details.
I tried with non protected pages and I can read them properly. Here is my code:
URL url = new URL("http://username:[email protected]:0000/test.xml");
URLConnection yc = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) 
        System.out.println(inputLine);
in.close();
© Stack Overflow or respective owner