Package com.alibaba.fastjson.util
Class IOUtils
- java.lang.Object
-
- com.alibaba.fastjson.util.IOUtils
-
public class IOUtils extends Object
- Author:
- wenshao[szujobs@hotmail.com]
-
-
Field Summary
Fields Modifier and Type Field Description static char[]ASCII_CHARSstatic char[]CAstatic PropertiesDEFAULT_PROPERTIESstatic char[]DIGITSstatic StringFASTJSON_COMPATIBLEWITHFIELDNAMEstatic StringFASTJSON_COMPATIBLEWITHJAVABEANstatic StringFASTJSON_PROPERTIESstatic boolean[]firstIdentifierFlagsstatic int[]IAstatic boolean[]identifierFlagsstatic char[]replaceCharsstatic byte[]specicalFlags_doubleQuotesstatic boolean[]specicalFlags_doubleQuotesFlagsstatic byte[]specicalFlags_singleQuotesstatic boolean[]specicalFlags_singleQuotesFlagsstatic CharsetUTF8
-
Constructor Summary
Constructors Constructor Description IOUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidclose(Closeable x)static voiddecode(CharsetDecoder charsetDecoder, ByteBuffer byteBuf, CharBuffer charByte)static byte[]decodeBase64(char[] chars, int offset, int charsLen)Decodes a BASE64 encoded char array that is known to be resonably well formatted.static byte[]decodeBase64(String s)Decodes a BASE64 encoded string that is known to be resonably well formatted.static byte[]decodeBase64(String chars, int offset, int charsLen)static intdecodeUTF8(byte[] sa, int sp, int len, char[] da)Deprecated.static intencodeUTF8(char[] chars, int offset, int len, byte[] bytes)static booleanfirstIdentifier(char ch)static voidgetChars(byte b, int index, char[] buf)static voidgetChars(int i, int index, char[] buf)Places characters representing the integer i into the character array buf.static voidgetChars(long i, int index, char[] buf)static StringgetStringProperty(String name)static booleanisIdent(char ch)static booleanisValidJsonpQueryParam(String value)static voidloadPropertiesFromFile()static StringreadAll(Reader reader)Deprecated.static intstringSize(int x)static intstringSize(long x)
-
-
-
Field Detail
-
FASTJSON_PROPERTIES
public static final String FASTJSON_PROPERTIES
- See Also:
- Constant Field Values
-
FASTJSON_COMPATIBLEWITHJAVABEAN
public static final String FASTJSON_COMPATIBLEWITHJAVABEAN
- See Also:
- Constant Field Values
-
FASTJSON_COMPATIBLEWITHFIELDNAME
public static final String FASTJSON_COMPATIBLEWITHFIELDNAME
- See Also:
- Constant Field Values
-
DEFAULT_PROPERTIES
public static final Properties DEFAULT_PROPERTIES
-
UTF8
public static final Charset UTF8
-
DIGITS
public static final char[] DIGITS
-
firstIdentifierFlags
public static final boolean[] firstIdentifierFlags
-
identifierFlags
public static final boolean[] identifierFlags
-
specicalFlags_doubleQuotes
public static final byte[] specicalFlags_doubleQuotes
-
specicalFlags_singleQuotes
public static final byte[] specicalFlags_singleQuotes
-
specicalFlags_doubleQuotesFlags
public static final boolean[] specicalFlags_doubleQuotesFlags
-
specicalFlags_singleQuotesFlags
public static final boolean[] specicalFlags_singleQuotesFlags
-
replaceChars
public static final char[] replaceChars
-
ASCII_CHARS
public static final char[] ASCII_CHARS
-
CA
public static final char[] CA
-
IA
public static final int[] IA
-
-
Method Detail
-
loadPropertiesFromFile
public static void loadPropertiesFromFile()
-
close
public static void close(Closeable x)
-
stringSize
public static int stringSize(long x)
-
getChars
public static void getChars(long i, int index, char[] buf)
-
getChars
public static void getChars(int i, int index, char[] buf)Places characters representing the integer i into the character array buf. The characters are placed into the buffer backwards starting with the least significant digit at the specified index (exclusive), and working backwards from there. Will fail if i == Integer.MIN_VALUE
-
getChars
public static void getChars(byte b, int index, char[] buf)
-
stringSize
public static int stringSize(int x)
-
decode
public static void decode(CharsetDecoder charsetDecoder, ByteBuffer byteBuf, CharBuffer charByte)
-
firstIdentifier
public static boolean firstIdentifier(char ch)
-
isIdent
public static boolean isIdent(char ch)
-
decodeBase64
public static byte[] decodeBase64(char[] chars, int offset, int charsLen)Decodes a BASE64 encoded char array that is known to be resonably well formatted. The method is about twice as fast as #decode(char[]). The preconditions are:
+ The array must have a line length of 76 chars OR no line separators at all (one line).
+ Line separator must be "\r\n", as specified in RFC 2045 + The array must not contain illegal characters within the encoded string
+ The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.- Parameters:
chars- The source array. Length 0 will return an empty array.nullwill throw an exception.- Returns:
- The decoded array of bytes. May be of length 0.
-
decodeBase64
public static byte[] decodeBase64(String chars, int offset, int charsLen)
-
decodeBase64
public static byte[] decodeBase64(String s)
Decodes a BASE64 encoded string that is known to be resonably well formatted. The method is about twice as fast as decode(String). The preconditions are:
+ The array must have a line length of 76 chars OR no line separators at all (one line).
+ Line separator must be "\r\n", as specified in RFC 2045 + The array must not contain illegal characters within the encoded string
+ The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.- Parameters:
s- The source string. Length 0 will return an empty array.nullwill throw an exception.- Returns:
- The decoded array of bytes. May be of length 0.
-
encodeUTF8
public static int encodeUTF8(char[] chars, int offset, int len, byte[] bytes)
-
decodeUTF8
public static int decodeUTF8(byte[] sa, int sp, int len, char[] da)Deprecated.
-
isValidJsonpQueryParam
public static boolean isValidJsonpQueryParam(String value)
-
-