All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.ipokerface.weixin.request.http.entity.ByteArrayEntity Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package cn.ipokerface.weixin.request.http.entity;

import cn.ipokerface.weixin.request.http.ContentType;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * Created by       PokerFace
 * Create Date      2019-12-27.
 * Email:           [email protected]
 * Version          1.0.0
 * 

* Description: */ public class ByteArrayEntity implements HttpEntity { private final ContentType contentType; private final byte[] content; private final int off, len; public ByteArrayEntity(byte[] content) { this(content, ContentType.DEFAULT_BINARY); } public ByteArrayEntity(byte[] content, ContentType contentType) { this(content, 0, content.length, contentType); } public ByteArrayEntity(byte[] content, int off, int len, ContentType contentType) { this.content = content; this.off = off; this.len = len; this.contentType = contentType; } @Override public ContentType getContentType() { return contentType; } @Override public long getContentLength() { return len; } @Override public InputStream getContent() throws IOException { return new ByteArrayInputStream(this.content, this.off, this.len); } @Override public void writeTo(OutputStream outstream) throws IOException { outstream.write(this.content, this.off, this.len); outstream.flush(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy