Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
716 views
in Technique[技术] by (71.8m points)

get - Exception in thread "main" java.io.IOException: Server returned HTTP response code: 405

ULR url = new URL(urlString);

HttpURLConnection con = (HttpURLConnection) url.openConnection();

con.setRequestMethod("GET");

con.connect();

BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); 

String inputLine;

StringBuffer response = new StringBuffer();

while ((inputLine = in.readLine()) != null) 

{

response.append(inputLine);

}

in.close();

System.out.println(response.toString());

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Please see HTTP status code: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

Your application should handle all HTTP standard Status Codes.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...