Example usage for com.squareup.okhttp ResponseBody byteStream

List of usage examples for com.squareup.okhttp ResponseBody byteStream

Introduction

In this page you can find the example usage for com.squareup.okhttp ResponseBody byteStream.

Prototype

public final InputStream byteStream() throws IOException 

Source Link

Usage

From source file:retrofit2.ProtoResponseBodyConverter.java

License:Apache License

@Override
public T convert(ResponseBody value) throws IOException {
    InputStream is = value.byteStream();
    try {/*from  w  ww  .j av  a  2  s.  c  o  m*/
        return parser.parseFrom(is);
    } catch (InvalidProtocolBufferException e) {
        throw new RuntimeException(e); // Despite extending IOException, this is data mismatch.
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException ignored) {
            }
        }
    }
}