Here you can find the source of toBufferedStream(InputStream is)
Parameter | Description |
---|---|
is | an input stream to convert to a buffered input stream |
Parameter | Description |
---|---|
NullPointerException | if the argument is null |
public static BufferedInputStream toBufferedStream(InputStream is)
//package com.java2s; //License from project: Open Source License import static com.google.common.base.Preconditions.*; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.InputStream; import java.io.OutputStream; public class Main { /**/*from w w w . j a v a2 s. c o m*/ * Returns the given {@link InputStream} cast to a {@link BufferedInputStream} if possible, * otherwise wraps it into a new {@link BufferedInputStream}. * * @param is an input stream to convert to a buffered input stream * @return a buffered input stream * @throws NullPointerException if the argument is null */ public static BufferedInputStream toBufferedStream(InputStream is) { checkNotNull(is, "input stream must not be null"); if (is instanceof BufferedInputStream) return (BufferedInputStream) is; return new BufferedInputStream(is); } /** * Returns the given {@link OutputStream} cast to a {@link BufferedOutputStream} if possible, * otherwise wraps it into a new {@link BufferedOutputStream}. * * @param os an output stream to convert to a buffered output stream * @return a buffered output stream * @throws NullPointerException if the argument is null */ public static BufferedOutputStream toBufferedStream(OutputStream os) { checkNotNull(os, "output stream must not be null"); if (os instanceof BufferedOutputStream) return (BufferedOutputStream) os; return new BufferedOutputStream(os); } }