package okhttp;import okhttp3.OkHttpClient;import okhttp3.Request;import okhttp3.Response;import java.io.IOException;import java.util.ArrayList;import java.util.Collections;import java.util.List;public class OkHttpGetExample {public static void main(String[] args) {OkHttpClient client = new OkHttpClient();// for (int i = 0; i < 1000; i++) {// String url = "https://eviapp.sanyevi.cn/common/service1/AppV3/server/info?srvId=" + i;// get(client, url);// }// get(client, "https://timor.tech/api/holiday/year/2024");//https://store.sany.com.cn/visa/M00/BB/45/CgASe2iC_jSAQ2wLAuJaThM0gTg472.apkfor (int i = 0; i < 10; i++) {// downLoad(client, "https://store.sany.com.cn/visa/M00/BB/45/CgASe2iC_jSAQ2wLAuJaThM0gTg472.apk");}List<String> temp = new ArrayList<>();String[] data = {"1", "2", "3"};Collections.addAll(temp, data);System.out.println(temp);}private static void downLoad(OkHttpClient client, String url) {// 创建GET请求Request request = new Request.Builder().url(url).build();try {// 发送请求并获取响应Response response = client.newCall(request).execute();// 检查响应是否成功System.out.println(response.isSuccessful());System.out.println(response.code());} catch (IOException e) {e.printStackTrace();}}private static void get(OkHttpClient client, String url) {// 创建GET请求Request request = new Request.Builder().url(url).build();try {// 发送请求并获取响应Response response = client.newCall(request).execute();// 检查响应是否成功if (response.isSuccessful()) {// 获取响应体数据String responseData = response.body().string();System.out.println("Response: " + responseData);} else {System.out.println("Request failed with code: " + response.code());}} catch (IOException e) {e.printStackTrace();}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。