首頁 文章 daima1

daima1

2021-12-27 11:19  瀏覽數:553  來源:小键人3994802    

public class NetUtil {
public static String doGet(String url1) {
try {
URL url = new URL(url1);
HttpURLConnection Connection = (HttpURLConnection) url.openConnection();
if (Connection.getResponseCode() == 200) {
InputStream inputStream = Connection.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder stringBuilder = new StringBuilder();
for (String line = ""; (line = bufferedReader.readLine()) != null; ) {
stringBuilder.append(line);
}
return stringBuilder.toString();
}
} catch (Exception e) {
e.printStackTrace();
}
return "";
}



聲明:以上文章均為用戶自行添加,僅供打字交流使用,不代表本站觀點,本站不承擔任何法律責任,特此聲明!如果有侵犯到您的權利,請及時聯系我們刪除。

字符:    改为:
去打字就可以设置个性皮肤啦!(O ^ ~ ^ O)