HTTP GET
new Thread(new Runnable(){
@Override
public void run() {
try {
URL url = new URL("https://google.com");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
InputStream is = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line;
StringBuilder response = new StringBuilder();
while ((line = reader.readLine()) != null) {
response.append(line);
response.append('\r');
}
reader.close();
System.out.println(response);
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();包成 class
使用 volley
Last updated