首頁 文章 连接数据库的代码

连接数据库的代码

2022-01-09 14:00  瀏覽數:575  來源:小键人4299743    

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)