org.apache.commons.io.output.ByteArrayOutputStream.toBufferedInputStream()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(13.9k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中org.apache.commons.io.output.ByteArrayOutputStream.toBufferedInputStream()方法的一些代码示例,展示了ByteArrayOutputStream.toBufferedInputStream()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteArrayOutputStream.toBufferedInputStream()方法的具体详情如下:
包路径:org.apache.commons.io.output.ByteArrayOutputStream
类名称:ByteArrayOutputStream
方法名:toBufferedInputStream

ByteArrayOutputStream.toBufferedInputStream介绍

[英]Gets the current contents of this byte stream as a Input Stream. The returned stream is backed by buffers of this stream, avoiding memory allocation and copy, thus saving space and time.
[中]获取此字节流的当前内容作为输入流。返回的流由this流的缓冲区支持,避免了内存分配和复制,从而节省了空间和时间。

代码示例

代码示例来源:origin: commons-io/commons-io

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray(InputStream)}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 *
 * @param input Stream to be fully buffered.
 * @param size the initial buffer size
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.5
 */
public static InputStream toBufferedInputStream(final InputStream input, final int size) throws IOException {
  return ByteArrayOutputStream.toBufferedInputStream(input, size);
}

代码示例来源:origin: commons-io/commons-io

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray(InputStream)}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 *
 * @param input Stream to be fully buffered.
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.0
 */
public static InputStream toBufferedInputStream(final InputStream input) throws IOException {
  return ByteArrayOutputStream.toBufferedInputStream(input);
}

代码示例来源:origin: commons-io/commons-io

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray()}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 *
 * @param input Stream to be fully buffered.
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.0
 */
public static InputStream toBufferedInputStream(final InputStream input)
    throws IOException {
  return toBufferedInputStream(input, 1024);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray()}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 *
 * @param input Stream to be fully buffered.
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.0
 */
public static InputStream toBufferedInputStream(final InputStream input)
    throws IOException {
  return toBufferedInputStream(input, 1024);
}

代码示例来源:origin: com.github.becauseQA/becauseQA-utils

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray(InputStream)}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 * 
 * @param input Stream to be fully buffered.
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.0
 */
public static InputStream toBufferedInputStream(InputStream input) throws IOException {
  return ByteArrayOutputStream.toBufferedInputStream(input);
}

代码示例来源:origin: org.onosproject/onlab-thirdparty

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray(InputStream)}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 * 
 * @param input Stream to be fully buffered.
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.0
 */
public static InputStream toBufferedInputStream(InputStream input) throws IOException {
  return ByteArrayOutputStream.toBufferedInputStream(input);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray(InputStream)}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 *
 * @param input Stream to be fully buffered.
 * @param size the initial buffer size
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.5
 */
public static InputStream toBufferedInputStream(final InputStream input, final int size) throws IOException {
  return ByteArrayOutputStream.toBufferedInputStream(input, size);
}

代码示例来源:origin: io.github.stephenc.docker/docker-client-shaded

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray(InputStream)}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 *
 * @param input Stream to be fully buffered.
 * @param size the initial buffer size
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.5
 */
public static InputStream toBufferedInputStream(final InputStream input, int size) throws IOException {
  return ByteArrayOutputStream.toBufferedInputStream(input, size);
}

代码示例来源:origin: com.github.becausetesting/commons

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray(InputStream)}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 * 
 * @param input Stream to be fully buffered.
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.0
 */
public static InputStream toBufferedInputStream(InputStream input) throws IOException {
  return ByteArrayOutputStream.toBufferedInputStream(input);
}

代码示例来源:origin: io.github.stephenc.docker/docker-client-shaded

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray(InputStream)}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 *
 * @param input Stream to be fully buffered.
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.0
 */
public static InputStream toBufferedInputStream(final InputStream input) throws IOException {
  return ByteArrayOutputStream.toBufferedInputStream(input);
}

代码示例来源:origin: Nextdoor/bender

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray(InputStream)}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 * 
 * @param input Stream to be fully buffered.
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.0
 */
public static InputStream toBufferedInputStream(InputStream input) throws IOException {
  return ByteArrayOutputStream.toBufferedInputStream(input);
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray(InputStream)}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 *
 * @param input Stream to be fully buffered.
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.0
 */
public static InputStream toBufferedInputStream(final InputStream input) throws IOException {
  return ByteArrayOutputStream.toBufferedInputStream(input);
}

代码示例来源:origin: io.github.stephenc.docker/docker-client-shaded

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray()}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 *
 * @param input Stream to be fully buffered.
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.0
 */
public static InputStream toBufferedInputStream(final InputStream input)
    throws IOException {
  return toBufferedInputStream(input, 1024);
}

代码示例来源:origin: Nextdoor/bender

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray()}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 * 
 * @param input Stream to be fully buffered.
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.0
 */
public static InputStream toBufferedInputStream(InputStream input)
    throws IOException {
  ByteArrayOutputStream output = new ByteArrayOutputStream();
  output.write(input);
  return output.toBufferedInputStream();
}

代码示例来源:origin: org.onosproject/onlab-thirdparty

/**
 * Fetches entire contents of an <code>InputStream</code> and represent
 * same data as result InputStream.
 * <p>
 * This method is useful where,
 * <ul>
 * <li>Source InputStream is slow.</li>
 * <li>It has network resources associated, so we cannot keep it open for
 * long time.</li>
 * <li>It has network timeout associated.</li>
 * </ul>
 * It can be used in favor of {@link #toByteArray()}, since it
 * avoids unnecessary allocation and copy of byte[].<br>
 * This method buffers the input internally, so there is no need to use a
 * <code>BufferedInputStream</code>.
 * 
 * @param input Stream to be fully buffered.
 * @return A fully buffered stream.
 * @throws IOException if an I/O error occurs
 * @since 2.0
 */
public static InputStream toBufferedInputStream(InputStream input)
    throws IOException {
  ByteArrayOutputStream output = new ByteArrayOutputStream();
  output.write(input);
  return output.toBufferedInputStream();
}

相关文章