Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.44 KB | None | 0 0
  1. [root@Test-LAPP01 test]# cat http.java
  2. import java.net.*;
  3. import java.io.*;
  4.  
  5. public class http {
  6.     public static void main(String[] args) throws Exception {
  7.  
  8.         URL alert = new URL("http://10.13.0.69:7878/testGet");
  9.         HttpURLConnection con = (HttpURLConnection) alert.openConnection();
  10.         con.setRequestMethod("GET");
  11.         int status = con.getResponseCode();
  12.         BufferedReader in = new BufferedReader(
  13.         new InputStreamReader(con.getInputStream()));
  14.         String inputLine;
  15.         StringBuffer content = new StringBuffer();
  16.         while ((inputLine = in.readLine()) != null) {
  17.                 content.append(inputLine);
  18.         }
  19.         in.close();
  20.     }
  21. }
  22.  
  23.  
  24. [root@Test-LAPP01 test]# javac http.java && java http
  25. Exception in thread "main" java.net.SocketException: Unexpected end of file from server
  26.         at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:851)
  27.         at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
  28.         at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:848)
  29.         at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
  30.         at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1587)
  31.         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
  32.         at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
  33.         at http.main(http.java:10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement