Home | History | Annotate | Download | only in guide
      1 package com.squareup.okhttp.guide;
      2 
      3 import com.squareup.okhttp.OkHttpClient;
      4 import com.squareup.okhttp.Request;
      5 import com.squareup.okhttp.Response;
      6 import java.io.IOException;
      7 
      8 public class GetExample {
      9   OkHttpClient client = new OkHttpClient();
     10 
     11   String run(String url) throws IOException {
     12     Request request = new Request.Builder()
     13         .url(url)
     14         .build();
     15 
     16     Response response = client.newCall(request).execute();
     17     return response.body().string();
     18   }
     19 
     20   public static void main(String[] args) throws IOException {
     21     GetExample example = new GetExample();
     22     String response = example.run("https://raw.github.com/square/okhttp/master/README.md");
     23     System.out.println(response);
     24   }
     25 }
     26