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

连接数据库的代码

2022-01-09 14:00  浏览数:584  来源:小键人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)