- java.lang.Object
-
- net.dongliu.commons.io.Inputs
-
- 直接已知子类:
InputStreams
public class Inputs extends java.lang.Object
Utils for InputStreams.
-
-
构造器概要
构造器 构造器 说明 Inputs()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static java.io.InputStream
concat(byte[] data, java.io.InputStream in)
Return a new InputStream that concat additional prepended data and InputStream.static java.io.InputStream
concat(java.io.InputStream... inputs)
Return a new InputStream that concat multi sub InputStreams.static java.io.InputStream
concat(java.util.List<java.io.InputStream> inputs)
Return a new InputStream that concat multi sub InputStreams.static long
discardAll(java.io.InputStream in)
Skip or read all data till EOF from InputStream.static java.io.InputStream
empty()
Return a empty input stream with no data.static byte[]
readAll(java.io.InputStream in)
Read all data in InputStream.static int
readExact(java.io.InputStream in, byte[] data, int offset, int len)
Read exact data with size, into data.static byte[]
readExact(java.io.InputStream in, int len)
Read exact data with size.static void
transferTo(java.io.InputStream in, java.io.OutputStream out)
Copy all data in InputStream to OutputStream.
-
-
-
方法详细资料
-
transferTo
public static void transferTo(java.io.InputStream in, java.io.OutputStream out)
Copy all data in InputStream to OutputStream. Both in and out are left unclosed when copy finished, or Exception occurred.- 抛出:
java.io.UncheckedIOException
- If anIOException
is thrown when accessing the underlying input or output stream
-
readAll
public static byte[] readAll(java.io.InputStream in)
Read all data in InputStream. The Stream is left unclosed when read finished, or Exception occurred.- 抛出:
java.io.UncheckedIOException
- If anIOException
is thrown when accessing the underlying input stream
-
readExact
public static int readExact(java.io.InputStream in, byte[] data, int offset, int len)
Read exact data with size, into data. The InputStream is not close after read or Exception occurred.- 返回:
- The real data size read. If InputStream does not has enough data for read, will return a size less than desired.
- 抛出:
java.io.UncheckedIOException
- If anIOException
is thrown when accessing the underlying input or output stream
-
readExact
public static byte[] readExact(java.io.InputStream in, int len)
Read exact data with size. The InputStream is not close after read or Exception occurred.- 返回:
- The data read. If InputStream does not has enough data for read, will return a byte array which len less than desired size.
- 抛出:
java.io.UncheckedIOException
- If anIOException
is thrown when accessing the underlying input or output stream
-
discardAll
public static long discardAll(java.io.InputStream in)
Skip or read all data till EOF from InputStream. The InputStream is left unclosed.- 返回:
- the total data size read
- 抛出:
java.io.UncheckedIOException
- If anIOException
is thrown when accessing the underlying input or output stream
-
empty
public static java.io.InputStream empty()
Return a empty input stream with no data.
-
concat
public static java.io.InputStream concat(java.util.List<java.io.InputStream> inputs)
Return a new InputStream that concat multi sub InputStreams. The close() method of returned InputStream will close all sub InputStreams.
-
concat
public static java.io.InputStream concat(java.io.InputStream... inputs)
Return a new InputStream that concat multi sub InputStreams. The close() method of returned InputStream will close all sub InputStreams.
-
concat
public static java.io.InputStream concat(byte[] data, java.io.InputStream in)
Return a new InputStream that concat additional prepended data and InputStream. The close() method of returned InputStream will close the passed in InputStream.
-
-