|
Multivalent API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectphelps.io.InputStreams
Utilities for InputStream
s.
DEVNULL
, DEVZERO
, DEVRANDOM
uncompress(InputStream, String)
, crc32(InputStream)
readFully(InputStream, byte[])
, readFully(InputStream, byte[], int, int)
OutputStream
or RandomAccess
toByteArray(InputStream)
/ toByteArray(InputStream,long)
Field Summary | |
---|---|
static java.io.InputStream |
DEVNULL
InputStream that always reports end of file ( -1 ) on read. |
static java.io.InputStream |
DEVRANDOM
InputStream that returns a random number (0..255) on read. |
static java.io.InputStream |
DEVZERO
InputStream that always returns 0 on read. |
Method Summary | |
---|---|
static long |
copy(java.io.InputStream is,
java.io.OutputStream out)
Convenience method for copy(in, out, false) . |
static long |
copy(java.io.InputStream is,
java.io.OutputStream out,
boolean fclose)
|
static long |
copy(java.io.InputStream is,
java.io.OutputStream out,
boolean fclose,
int length)
Copy contents of is to out. |
static void |
copy(java.io.InputStream is,
com.pt.io.RandomAccess ra)
Copies rest of is to ra, which should be writable. |
static long |
crc32(java.io.InputStream is)
Returns CRC32 checksum of is. |
static void |
readFully(java.io.InputStream is,
byte[] b)
|
static void |
readFully(java.io.InputStream is,
byte[] b,
int off,
int len)
Reads exactly len bytes from this file into the byte array. |
static void |
skipFully(java.io.InputStream is,
long length)
Skips length bytes, unless reach end of stream. |
static byte[] |
toByteArray(java.io.InputStream is)
Reads the rest of is and returns contents. |
static byte[] |
toByteArray(java.io.InputStream is,
long estlength)
Reads the rest of is and returns contents. |
static java.io.InputStream |
uncompress(java.io.InputStream is,
java.lang.String type)
Wraps is with another stream that uncompresses it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.io.InputStream DEVNULL
-1
) on read.
public static final java.io.InputStream DEVZERO
0
on read.
public static final java.io.InputStream DEVRANDOM
Method Detail |
---|
public static long crc32(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public static void readFully(java.io.InputStream is, byte[] b, int off, int len) throws java.io.IOException
java.io.EOFException
- if this file reaches the end before reading all the bytes.
java.io.IOException
public static void readFully(java.io.InputStream is, byte[] b) throws java.io.IOException
java.io.IOException
public static void skipFully(java.io.InputStream is, long length) throws java.io.IOException
java.io.IOException
public static java.io.InputStream uncompress(java.io.InputStream is, java.lang.String type) throws java.io.IOException
Z
, gz
, bz2
/bzip2
,
and all HTTP/1.1 Content-Encoding
s (gzip
, compress
, deflate
, identity
).
type
- filename with compression suffix, or compression type (LZW
, gzip
, deflate
, bzip2
).
java.io.IOException
Files.getEncoding(String)
public static long copy(java.io.InputStream is, java.io.OutputStream out) throws java.io.IOException
copy(in, out, false)
.
java.io.IOException
public static long copy(java.io.InputStream is, java.io.OutputStream out, boolean fclose) throws java.io.IOException
java.io.IOException
public static long copy(java.io.InputStream is, java.io.OutputStream out, boolean fclose, int length) throws java.io.IOException
true
then close both streams,
so a stream-to-stream copy is as simple as copy(new InputStream(), new OutputStream(), true)
.
Neither stream needs to be buffered as block reads and writes are used (which is all that buffered streams do).
java.io.IOException
public static void copy(java.io.InputStream is, com.pt.io.RandomAccess ra) throws java.io.IOException
java.io.IOException
public static byte[] toByteArray(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public static byte[] toByteArray(java.io.InputStream is, long estlength) throws java.io.IOException
java.io.IOException
|
Multivalent API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |