![JAR search and dependency download from the Maven repository](/logo.png)
co.easimart.EasimartByteArrayHttpBody Maven / Gradle / Ivy
package co.easimart;
import co.easimart.http.EasimartHttpBody;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
/** package */ class EasimartByteArrayHttpBody extends EasimartHttpBody {
/* package */ final byte[] content;
/* package */ final InputStream contentInputStream;
public EasimartByteArrayHttpBody(String content, String contentType)
throws UnsupportedEncodingException {
this(content.getBytes("UTF-8"), contentType);
}
public EasimartByteArrayHttpBody(byte[] content, String contentType) {
super(contentType, content.length);
this.content = content;
this.contentInputStream = new ByteArrayInputStream(content);
}
@Override
public InputStream getContent() {
return contentInputStream;
}
@Override
public void writeTo(OutputStream out) throws IOException {
if (out == null) {
throw new IllegalArgumentException("Output stream may not be null");
}
out.write(content);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy