aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes java.net.SocketException (while getting data from an url) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "java.net.SocketException (while getting data from an url)" Watch "java.net.SocketException (while getting data from an url)" New topic
Author

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

subodh varshney
Greenhorn

Joined: Aug 01, 2005
Posts: 11
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.net.SocketException (while getting data from an url)