2018年8月11日 星期六

okhttp 設置 big5


      @Override
      public void onResponse(Call call, Response response) throws IOException {
//             final String string = response.body().string();
                byte[] b = response.body().bytes(); //获取数据的bytes
               String info = new String(b, "Big5"); //然后将其转为Big5
             }
        }); 
 or 
            @Override
            public void onResponse(Call call, Response response) throws IOException {
             //   final String string = response.body().string();
            //okhttp…response.body().string()中的string()方法只能调用一次………. 
              String html = new String(response.body().bytes(), "big5");  //轉 big5

            }
        });
 -------------------------------------------------------------
okhttp异常
java.lang.IllegalStateException: closed
okhttp3.internal.http.Http1xStream$ChunkedSource.read(Http1xStream.java:418)
okhttp …response.body().string()中的string()方法只能调用一次 

沒有留言:

張貼留言