Search in sources :

Example 11 with FastByteArrayOutputStream

use of cn.hutool.core.io.FastByteArrayOutputStream in project hutool by looly.

the class MultipartRequestInputStream method readString.

// ---------------------------------------------------------------- copy
/**
 * 读取字节流,直到下一个boundary
 *
 * @param charset 编码,null表示系统默认编码
 * @return 读取的字符串
 * @throws IOException 读取异常
 */
public String readString(Charset charset) throws IOException {
    final FastByteArrayOutputStream out = new FastByteArrayOutputStream();
    copy(out);
    return out.toString(charset);
}
Also used : FastByteArrayOutputStream(cn.hutool.core.io.FastByteArrayOutputStream)

Example 12 with FastByteArrayOutputStream

use of cn.hutool.core.io.FastByteArrayOutputStream in project hutool by looly.

the class HttpResponse method readBody.

/**
 * 读取主体,忽略EOFException异常
 *
 * @param in 输入流
 * @throws IORuntimeException IO异常
 */
private void readBody(InputStream in) throws IORuntimeException {
    if (ignoreBody) {
        return;
    }
    final long contentLength = contentLength();
    final FastByteArrayOutputStream out = new FastByteArrayOutputStream((int) contentLength);
    copyBody(in, out, contentLength, null);
    this.bodyBytes = out.toByteArray();
}
Also used : FastByteArrayOutputStream(cn.hutool.core.io.FastByteArrayOutputStream)

Aggregations

FastByteArrayOutputStream (cn.hutool.core.io.FastByteArrayOutputStream)12 UtilException (cn.hutool.core.exceptions.UtilException)3 Serializable (java.io.Serializable)3 ObjectOutputStream (java.io.ObjectOutputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ObjectInputStream (java.io.ObjectInputStream)1 PrintStream (java.io.PrintStream)1 GZIPOutputStream (java.util.zip.GZIPOutputStream)1