2015-09-01 45 views
3

@Streaming因为没有body().in()(再),这个代码不改造2工作:支持在改造2

interface Service {   
    @Get("...") 
    @Streaming 
    Response getData(); 
} 

try (InputStream in = service.getData().getBody().in()) { 
    ... 
} 

唯一的方法,我发现是这样的。它是否正确?

try (InputStream in = service.getData().raw().body().byteStream()) { 
    ... 
} 

回答

0

有点晚了,但我今天所以这里有同样的问题是我的发现和使用:

interface Service { 
    @GET("...") 
    @Streaming 
    Call<ResponseBody> getData(); 
} 


Call<ResponseBody> call = service.getData(); 
try { 
    InputStream in = call.execute().body().byteStream(); 
    (...) 
} catch (IOException e) {...}