Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.net.SocketException (while getting data from an url)

 
subodh varshney
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
i m using following code for url connection, and getting error.
Please help me.

URL url = new URL(urlString);
HttpsURLConnection conn=(HttpsURLConnection)url.openConnection();
conn.setHostnameVerifier(new MyHostnameVerifier());
conn.setAllowUserInteraction(true);
conn.setDoOutput(false);
conn.setRequestMethod("GET");
conn.getContent();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String str="";
String str1="";
while ((str = in.readLine()) != null) {
if(!str.equalsIgnoreCase(""))
System.out.println("STR:::::"+str);
str1+=str+"\n";
}
in.close();

<-------------------I am getting following error ---------------->

java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:802)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:702)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:583)
at java.net.URLConnection.getContent(URLConnection.java:582)Unable to send the message
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic