HttpsURLConnection: Connection Timed out error

前端 未结 5 1833
情深已故
情深已故 2020-12-07 04:21

I have a simple code for setting up a https connection to google and printing the response obtained.

import java.io.OutputStreamWriter;
import java.net.URL;
         


        
5条回答
  •  一向
    一向 (楼主)
    2020-12-07 04:54

    You should not try to write into stream when you are performing HTTP GET. You should read from input stream instead:

    BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String line = null;
    while((line = reader.readLine()) != null) {
       //........
    }
    

提交回复
热议问题