
com.github.davidmoten.odata.client.StreamProviderBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of odata-client-runtime Show documentation
Show all versions of odata-client-runtime Show documentation
OData client runtime for use with generated code
The newest version!
package com.github.davidmoten.odata.client;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
public interface StreamProviderBase {
/**
* Returns a {@link InputStream} for the requested content every time this
* method is called. Note that the returned `InputStream` must be closed
* after read otherwise the http client may hang on a later request. Use the
* {@link StreamProvider#contentType()} method to get the mime type of the content delivered
* via the InputStream.
*
* @return InputStream for the requested content that must be closed after use
*/
InputStream get();
default byte[] getBytes() {
try (InputStream in = get()) {
return Util.toByteArray(in);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
default String getStringUtf8() {
return new String(getBytes(), StandardCharsets.UTF_8);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy