无法解析构造函数Builder()

时间:2018-07-13 14:19:53

标签: android okhttp

使用okhttp
我在新的Request.Builder()

行上遇到无法解决的构造函数错误
new_plugins_configurationSet

不知道为什么会出现此错误。任何帮助将不胜感激。
编辑:我的进口货

public final OkHttpClient client = new OkHttpClient();

public void run() throws Exception {
    Request request = new Request.Builder()
            .url("https://publicobject.com/helloworld.txt")
            .build();

    try (Response response = client.newCall(request).execute()) {
        if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);

        Headers responseHeaders = response.headers();
        for (int i = 0; i < responseHeaders.size(); i++) {
            System.out.println(responseHeaders.name(i) + ": " + responseHeaders.value(i));
        }

        System.out.println(response.body().string());
    }
}

0 个答案:

没有答案