限定符和类型 | 方法和说明 |
---|---|
static void |
copy(java.io.InputStream inp,
java.io.OutputStream out) |
static byte[] |
peekFirst8Bytes(java.io.InputStream stream)
Peeks at the first 8 bytes of the stream.
|
static byte[] |
peekFirstNBytes(java.io.InputStream stream,
int limit)
Peeks at the first N bytes of the stream.
|
static java.io.InputStream |
prepareToCheckMagic(java.io.InputStream stream)
Checks if an
InputStream can be reseted (i.e. used for checking the header magic) and wraps it if not |
static FileMagic |
valueOf(byte[] magic) |
static FileMagic |
valueOf(java.io.InputStream inp)
Get the file magic of the supplied InputStream (which MUST
support mark and reset).
|
static FileMagic |
valueOf(java.lang.String name)
返回带有指定名称的该类型的枚举常量。
|
static FileMagic[] |
values()
按照声明该枚举类型的常量的顺序, 返回
包含这些常量的数组。
|
public static final FileMagic ZIP
public static final FileMagic XML
public static final FileMagic PDF
public static final FileMagic UNKNOWN
public static FileMagic[] values()
for (FileMagic c : FileMagic.values()) System.out.println(c);
public static FileMagic valueOf(java.lang.String name)
name
- 要返回的枚举常量的名称。java.lang.IllegalArgumentException
- 如果该枚举类型没有带有指定名称的常量java.lang.NullPointerException
- 如果参数为空值public static FileMagic valueOf(byte[] magic)
public static FileMagic valueOf(java.io.InputStream inp) throws java.io.IOException
If unsure if your InputStream does support mark / reset,
use prepareToCheckMagic(InputStream)
to wrap it and make
sure to always use that, and not the original!
Even if this method returns UNKNOWN
it could potentially mean,
that the ZIP stream has leading junk bytes
inp
- An InputStream which supports either mark/resetjava.io.IOException
public static java.io.InputStream prepareToCheckMagic(java.io.InputStream stream)
InputStream
can be reseted (i.e. used for checking the header magic) and wraps it if notstream
- stream to be checked for wrappingpublic static byte[] peekFirst8Bytes(java.io.InputStream stream) throws java.io.IOException, EmptyFileException
EmptyFileException
- if the stream is emptyjava.io.IOException
public static byte[] peekFirstNBytes(java.io.InputStream stream, int limit) throws java.io.IOException, EmptyFileException
EmptyFileException
- if the stream is emptyjava.io.IOException
public static void copy(java.io.InputStream inp, java.io.OutputStream out) throws java.io.IOException
java.io.IOException