|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |
java.lang.Objectjava.lang.Enum<UnicodeBOM>
org.jagatoo.util.io.UnicodeBOM
public enum UnicodeBOM
Unicode BOM model.
Enum Constant Summary | |
---|---|
BOCU_1
|
|
GB_18030
|
|
SUSU
|
|
UTF_1
|
|
UTF_16_BE
|
|
UTF_16_LE
|
|
UTF_32_BE
|
|
UTF_32_LE
|
|
UTF_7a
|
|
UTF_7b
|
|
UTF_7c
|
|
UTF_7d
|
|
UTF_8
|
|
UTF_EBCDIC
|
Method Summary | |
---|---|
int |
getBOM()
Gets the BOM code. |
java.nio.charset.Charset |
getCharset()
Gets the corresponding Charset or null , if not available. |
int |
getLength()
The theoretical byte length. |
int |
getLength(int bom)
The actual byte length of the given BOM. |
static UnicodeBOM |
readBOM(java.io.File file)
Only ready up to the first four bytes of the file and tries to recognize the unicode BOM from these data. |
static UnicodeBOM |
recognize(int bom)
Attempts to recognize the passed unicode BOM. |
static UnicodeBOM |
removeBOM(java.io.File file,
java.io.File temp)
Removes the BOM bytes from the input file, if and only if one was found. |
static UnicodeBOM |
removeBOM(java.io.File file,
java.io.File temp,
java.nio.charset.Charset targetCharset)
Removes the BOM bytes from the input file, if and only if one was found. |
static UnicodeBOM |
skipBOM(java.io.InputStream in)
Skips the bytes, covered by a possible unicode BOM, or, if not recognized, does nothing. |
static UnicodeBOM |
valueOf(int bom)
Attempts to recognize the passed unicode BOM. |
static UnicodeBOM |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. |
static UnicodeBOM[] |
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
Methods inherited from class java.lang.Enum |
---|
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Enum Constant Detail |
---|
public static final UnicodeBOM UTF_8
public static final UnicodeBOM UTF_16_BE
public static final UnicodeBOM UTF_16_LE
public static final UnicodeBOM UTF_32_BE
public static final UnicodeBOM UTF_32_LE
public static final UnicodeBOM UTF_7a
public static final UnicodeBOM UTF_7b
public static final UnicodeBOM UTF_7c
public static final UnicodeBOM UTF_7d
public static final UnicodeBOM UTF_1
public static final UnicodeBOM UTF_EBCDIC
public static final UnicodeBOM SUSU
public static final UnicodeBOM BOCU_1
public static final UnicodeBOM GB_18030
Method Detail |
---|
public static UnicodeBOM[] values()
for (UnicodeBOM c : UnicodeBOM.values()) System.out.println(c);
public static UnicodeBOM valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.
java.lang.IllegalArgumentException
- if this enum type has no constant
with the specified name
java.lang.NullPointerException
- if the argument is nullpublic final int getBOM()
public final int getLength()
public final int getLength(int bom)
bom
- the 4 byte bom (first 4 bytes of the file)
public final java.nio.charset.Charset getCharset()
Charset
or null
, if not available.
Charset
or null
, if not available.public static UnicodeBOM recognize(int bom)
Attempts to recognize the passed unicode BOM. If it can't be recognized, null
is returned.
The difference to the valueOf(int)
method is, that recognize(int)
expects
the first four bytes of the file, where a BOM of length 3 appears in the first three byte
and hence the value is shifted to the left by one byte
while valueOf(int)
takes the concrete BOM code.
bom
- the 4 byte bom (first 4 bytes of the file)
UnicodeBOM
or null
.valueOf(int)
public static UnicodeBOM valueOf(int bom)
Attempts to recognize the passed unicode BOM. If it can't be recognized, null
is returned.
The difference to the recognize(int)
method is, that valueOf(int)
takes the concrete BOM code
while recognize(int)
expects the first four bytes of the file, where a BOM of length 3 appears in the first three byte
and hence the value is shifted to the left by one byte.
bom
- the BOM code
UnicodeBOM
or null
.recognize(int)
public static UnicodeBOM skipBOM(java.io.InputStream in) throws java.io.IOException
InputStream
needs to support mark/reset.
in
-
UnicodeBOM
or null
.
java.io.IOException
- if anything went wrong.public static UnicodeBOM readBOM(java.io.File file) throws java.io.IOException
file
- the file to probe
UnicodeBOM
or null
.
java.io.IOException
- if something went wrongpublic static UnicodeBOM removeBOM(java.io.File file, java.io.File temp, java.nio.charset.Charset targetCharset) throws java.io.IOException
file
- the input filetemp
- the temp file nametargetCharset
- the charset to use for the new file or null
for default
UnicodeBOM
or null
.
java.io.IOException
- if something went wrongpublic static UnicodeBOM removeBOM(java.io.File file, java.io.File temp) throws java.io.IOException
file
- the input filetemp
- the temp file name
UnicodeBOM
or null
.
java.io.IOException
- if something went wrong
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | ENUM CONSTANTS | FIELD | METHOD | DETAIL: ENUM CONSTANTS | FIELD | METHOD |