android - How to convert the response from Okhttp into inputstream -


code:

  public static string getrequestnopayload(string urlstring, string loginapi, string musername) throws exception {         response response;         try{             client.setconnecttimeout(20, timeunit.seconds); // connect timeout             client.setreadtimeout(20, timeunit.seconds);    // socket timeout             request request = new request.builder()                     .url(urlstring)                     .addheader("username",loginapi)                     .addheader("password",musername)                     .build();              response = client.newcall(request).execute();          }catch(exception e){             throw e;         }         return response.body().string();     } 

what trying do: trying convert response.body() inputstream. how achieve this

you can inputstream through bytestream()

e.g.

 inputstream = response.body().bytestream(); 

to return have change method's signature. string inputstream


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -