com.alibaba.fastjson.util
Class IOUtils
- java.lang.Object
-
- com.alibaba.fastjson.util.IOUtils
public class IOUtils extends Object
- Author:
- wenshao[[email protected]]
-
Field Summary
Fields Modifier and Type Field and Description static char[]
ASCII_CHARS
static char[]
CA
static Properties
DEFAULT_PROPERTIES
static char[]
DIGITS
static String
FASTJSON_COMPATIBLEWITHFIELDNAME
static String
FASTJSON_COMPATIBLEWITHJAVABEAN
static String
FASTJSON_PROPERTIES
static boolean[]
firstIdentifierFlags
static int[]
IA
static boolean[]
identifierFlags
static char[]
replaceChars
static byte[]
specicalFlags_doubleQuotes
static boolean[]
specicalFlags_doubleQuotesFlags
static byte[]
specicalFlags_singleQuotes
static boolean[]
specicalFlags_singleQuotesFlags
static Charset
UTF8
Constructor Summary
Constructors Constructor and Description IOUtils()
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description static void
close(Closeable x)
static void
decode(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 int
decodeUTF8(byte[] sa, int sp, int len, char[] da)
Deprecated.static int
encodeUTF8(char[] chars, int offset, int len, byte[] bytes)
static boolean
firstIdentifier(char ch)
static void
getChars(byte b, int index, char[] buf)
static void
getChars(int i, int index, char[] buf)
Places characters representing the integer i into the character array buf.static void
getChars(long i, int index, char[] buf)
static String
getStringProperty(String name)
static boolean
isIdent(char ch)
static boolean
isValidJsonpQueryParam(String value)
static void
loadPropertiesFromFile()
static String
readAll(Reader reader)
Deprecated.static int
stringSize(int x)
static int
stringSize(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.null
will 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.null
will 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)
Copyright © 2012–2021 Alibaba Group. All rights reserved.