1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| package com.star;
import okhttp3.*;
import java.io.IOException;
public class RequsetTest { public static void main(String[] args) throws IOException { OkHttpClient client = new OkHttpClient.Builder().build(); final Request request = new Request.Builder().url("https://github.com/").build(); Call call = client.newCall(request); call.enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { System.out.println("Fail"); }
@Override public void onResponse(Call call, Response response) throws IOException { System.out.println(response.body().string()); } }); System.out.println(1);
} }
|