Class IOUtils

java.lang.Object
com.alibaba.fastjson2.util.IOUtils

public class IOUtils extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int[]
     
    static final long[]
     
    static final long
     
    static final short[]
     
    static final int[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
     
    static int
    convEndian(boolean big, int n)
     
    static long
    convEndian(boolean big, long n)
     
    static int
    decodeUTF8(byte[] src, int off, int len, byte[] dst)
     
    static int
    decodeUTF8(byte[] src, int off, int len, char[] dst)
     
    static int
    digit(int d)
     
    static int
    digit1(byte[] bytes, int off)
     
    static int
    digit1(char[] chars, int off)
     
    static int
    digit2(byte[] bytes, int off)
     
    static int
    digit2(char[] chars, int off)
     
    static int
    digit3(byte[] bytes, int off)
     
    static int
    digit3(char[] chars, int off)
     
    static int
    digit4(byte[] bytes, int off)
     
    static int
    digit4(char[] chars, int off)
     
    static int
    encodeUTF8(byte[] src, int offset, int len, byte[] dst, int dp)
     
    static int
    encodeUTF8(char[] src, int offset, int len, byte[] dst, int dp)
     
    static byte
    getByte(byte[] str, int pos)
     
    static char
    getChar(byte[] str, int pos)
     
    static char
    getChar(char[] buf, int pos)
     
    static void
    getChars(int i, int index, byte[] buf)
     
    static void
    getChars(int i, int index, char[] buf)
     
    static void
    getChars(long i, int index, byte[] buf)
     
    static void
    getChars(long i, int index, char[] buf)
     
    static int
    getIntBE(byte[] bytes, int offset)
     
    static int
    getIntLE(byte[] bytes, int offset)
     
    static int
    getIntLE(char[] bytes, int offset)
     
    static int
    getIntUnaligned(byte[] bytes, int offset)
     
    static int
    getIntUnaligned(char[] bytes, int offset)
     
    static long
    getLongBE(byte[] bytes, int offset)
     
    static long
    getLongLE(byte[] bytes, int offset)
     
    static long
    getLongLE(char[] bytes, int offset)
     
    static long
    getLongUnaligned(byte[] bytes, int offset)
     
    static long
    getLongUnaligned(char[] bytes, int offset)
     
    static short
    getShortBE(byte[] bytes, int offset)
     
    static short
    getShortLE(byte[] bytes, int offset)
     
    static short
    getShortUnaligned(byte[] bytes, int offset)
     
    static short
    hex2(int i)
     
    static short
    hex2U(int i)
     
    static int
    hex4U(int i)
     
    static int
    hexDigit4(byte[] bytes, int offset)
     
    static int
    hexDigit4(char[] bytes, int offset)
     
    static int
    indexOfChar(byte[] value, int ch, int fromIndex, int max)
     
    static int
    indexOfChar(char[] value, int ch, int fromIndex, int max)
     
    static int
    indexOfDoubleQuote(byte[] value, int fromIndex, int max)
     
    static int
    indexOfDoubleQuoteV(byte[] value, int fromIndex, int max)
     
    static int
    indexOfLineSeparator(byte[] value, int fromIndex, int max)
     
    static int
    indexOfLineSeparatorV(byte[] value, int fromIndex, int max)
     
    static int
    indexOfQuote(byte[] value, int quote, int fromIndex, int max)
     
    static int
    indexOfQuoteV(byte[] value, int quote, int fromIndex, int max)
     
    static int
    indexOfSlash(byte[] value, int fromIndex, int max)
     
    static int
    indexOfSlashV(byte[] value, int fromIndex, int max)
     
    static boolean
    isALSE(byte[] buf, int pos)
     
    static boolean
    isALSE(char[] buf, int pos)
     
    static boolean
    isASCII(byte[] bytes)
     
    static boolean
    isASCII(byte[] bytes, int off, int len)
     
    static boolean
     
    static boolean
    isDigit(int ch)
     
    static boolean
    isDigit2(byte[] bytes, int off)
     
    static boolean
    isDigit2(char[] bytes, int off)
     
    static boolean
    isLatin1(char[] chars, int off, int len)
     
    static boolean
    isNonSlashASCII(byte[] bytes, int off, int len)
     
    static boolean
    isNULL(byte[] buf, int pos)
     
    static boolean
    isNULL(char[] buf, int pos)
     
    static boolean
    isNumber(byte[] chars, int off, int len)
     
    static boolean
    isNumber(char[] chars, int off, int len)
     
    static boolean
     
    static boolean
    isTRUE(byte[] buf, int pos)
     
    static boolean
    isTRUE(char[] buf, int pos)
     
    static boolean
    isUTF8BOM(byte[] bytes, int off)
     
    static long
    lines(File file)
     
    static long
     
    static boolean
    notALSE(byte[] buf, int pos)
     
    static boolean
    notALSE(char[] buf, int pos)
     
    static boolean
    notNULL(byte[] buf, int pos)
     
    static boolean
    notNULL(char[] buf, int pos)
     
    static boolean
    notTRUE(byte[] buf, int pos)
     
    static boolean
    notTRUE(char[] buf, int pos)
     
    static int
    parseInt(byte[] bytes, int off, int len)
     
    static int
    putBoolean(byte[] bytes, int off, boolean v)
     
    static int
    putBoolean(char[] chars, int off, boolean v)
     
    static void
    putIntBE(byte[] buf, int pos, int v)
     
    static void
    putIntLE(byte[] buf, int pos, int v)
     
    static void
    putIntLE(char[] buf, int pos, int v)
     
    static void
    putIntUnaligned(byte[] buf, int pos, int v)
     
    static void
    putIntUnaligned(char[] buf, int pos, int v)
     
    static void
    putLongBE(byte[] buf, int pos, long v)
     
    static void
    putLongLE(byte[] buf, int pos, long v)
     
    static void
    putLongLE(char[] buf, int pos, long v)
     
    static void
    putLongUnaligned(byte[] buf, int pos, long v)
     
    static void
    putLongUnaligned(char[] buf, int pos, long v)
     
    static void
    putNULL(byte[] buf, int pos)
     
    static void
    putNULL(char[] buf, int pos)
     
    static void
    putShortBE(byte[] buf, int pos, short v)
     
    static void
    putShortLE(byte[] buf, int pos, short v)
     
    static void
    putShortUnaligned(byte[] buf, int pos, short v)
     
    static int
    stringSize(int x)
     
    static int
    stringSize(long x)
     
    static int
    utf16Hex2(int i)
     
    static long
    utf16Hex4U(long i)
     
    static int
    writeDecimal(byte[] buf, int off, long unscaledVal, int scale)
     
    static int
    writeDecimal(char[] buf, int off, long unscaledVal, int scale)
     
    static void
    writeDigitPair(byte[] buf, int charPos, int value)
     
    static void
    writeDigitPair(char[] buf, int charPos, int value)
     
    static int
    writeInt16(byte[] buf, int pos, short value)
     
    static int
    writeInt16(char[] buf, int pos, short value)
     
    static int
    writeInt32(byte[] buf, int off, long val)
     
    static int
    writeInt32(char[] buf, int off, long val)
     
    static int
    writeInt64(byte[] buf, int off, long val)
     
    static int
    writeInt64(char[] buf, int off, long val)
     
    static int
    writeInt8(byte[] buf, int pos, byte value)
     
    static int
    writeInt8(char[] buf, int pos, byte value)
     
    static int
    writeLocalDate(byte[] bytes, int off, int year, int month, int dayOfMonth)
     
    static int
    writeLocalDate(char[] chars, int off, int year, int month, int dayOfMonth)
     
    static void
    writeLocalTime(byte[] bytes, int off, int hour, int minute, int second)
     
    static int
    writeLocalTime(byte[] bytes, int off, LocalTime time)
     
    static void
    writeLocalTime(char[] chars, int off, int hour, int minute, int second)
     
    static int
    writeLocalTime(char[] chars, int off, LocalTime time)
     
    static int
    writeNano(byte[] bytes, int off, int nano)
     
    static int
    writeNano(char[] chars, int off, int nano)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DOT_X0

      public static final long DOT_X0
    • DIGITS_K_32

      public static final int[] DIGITS_K_32
    • DIGITS_K_64

      public static final long[] DIGITS_K_64
    • PACKED_DIGITS

      public static final short[] PACKED_DIGITS
    • PACKED_DIGITS_UTF16

      public static final int[] PACKED_DIGITS_UTF16
  • Constructor Details

    • IOUtils

      public IOUtils()
  • Method Details

    • writeDigitPair

      public static void writeDigitPair(byte[] buf, int charPos, int value)
    • writeDigitPair

      public static void writeDigitPair(char[] buf, int charPos, int value)
    • stringSize

      public static int stringSize(int x)
    • stringSize

      public static int stringSize(long x)
    • getChars

      public static void getChars(int i, int index, byte[] buf)
    • getChars

      public static void getChars(int i, int index, char[] buf)
    • getChars

      public static void getChars(long i, int index, byte[] buf)
    • getChars

      public static void getChars(long i, int index, char[] buf)
    • writeDecimal

      public static int writeDecimal(byte[] buf, int off, long unscaledVal, int scale)
    • writeDecimal

      public static int writeDecimal(char[] buf, int off, long unscaledVal, int scale)
    • encodeUTF8

      public static int encodeUTF8(byte[] src, int offset, int len, byte[] dst, int dp)
    • encodeUTF8

      public static int encodeUTF8(char[] src, int offset, int len, byte[] dst, int dp)
    • isNumber

      public static boolean isNumber(String str)
    • isNumber

      public static boolean isNumber(char[] chars, int off, int len)
    • isNumber

      public static boolean isNumber(byte[] chars, int off, int len)
    • close

      public static void close(Closeable x)
    • decodeUTF8

      public static int decodeUTF8(byte[] src, int off, int len, byte[] dst)
    • decodeUTF8

      public static int decodeUTF8(byte[] src, int off, int len, char[] dst)
    • lines

      public static long lines(File file) throws Exception
      Throws:
      Exception
    • lines

      public static long lines(InputStream in) throws Exception
      Throws:
      Exception
    • writeLocalDate

      public static int writeLocalDate(byte[] bytes, int off, int year, int month, int dayOfMonth)
    • writeLocalDate

      public static int writeLocalDate(char[] chars, int off, int year, int month, int dayOfMonth)
    • writeLocalTime

      public static void writeLocalTime(byte[] bytes, int off, int hour, int minute, int second)
    • writeLocalTime

      public static int writeLocalTime(byte[] bytes, int off, LocalTime time)
    • writeNano

      public static int writeNano(byte[] bytes, int off, int nano)
    • writeNano

      public static int writeNano(char[] chars, int off, int nano)
    • writeLocalTime

      public static void writeLocalTime(char[] chars, int off, int hour, int minute, int second)
    • writeLocalTime

      public static int writeLocalTime(char[] chars, int off, LocalTime time)
    • writeInt64

      public static int writeInt64(byte[] buf, int off, long val)
    • writeInt64

      public static int writeInt64(char[] buf, int off, long val)
    • writeInt8

      public static int writeInt8(byte[] buf, int pos, byte value)
    • writeInt8

      public static int writeInt8(char[] buf, int pos, byte value)
    • writeInt16

      public static int writeInt16(byte[] buf, int pos, short value)
    • writeInt16

      public static int writeInt16(char[] buf, int pos, short value)
    • writeInt32

      public static int writeInt32(byte[] buf, int off, long val)
    • writeInt32

      public static int writeInt32(char[] buf, int off, long val)
    • getByte

      public static byte getByte(byte[] str, int pos)
    • getChar

      public static char getChar(char[] buf, int pos)
    • getChar

      public static char getChar(byte[] str, int pos)
    • putShortBE

      public static void putShortBE(byte[] buf, int pos, short v)
    • putShortLE

      public static void putShortLE(byte[] buf, int pos, short v)
    • putIntBE

      public static void putIntBE(byte[] buf, int pos, int v)
    • putIntLE

      public static void putIntLE(byte[] buf, int pos, int v)
    • putIntLE

      public static void putIntLE(char[] buf, int pos, int v)
    • putShortUnaligned

      public static void putShortUnaligned(byte[] buf, int pos, short v)
    • putIntUnaligned

      public static void putIntUnaligned(char[] buf, int pos, int v)
    • putIntUnaligned

      public static void putIntUnaligned(byte[] buf, int pos, int v)
    • putLongLE

      public static void putLongLE(char[] buf, int pos, long v)
    • putLongUnaligned

      public static void putLongUnaligned(char[] buf, int pos, long v)
    • putLongUnaligned

      public static void putLongUnaligned(byte[] buf, int pos, long v)
    • putLongBE

      public static void putLongBE(byte[] buf, int pos, long v)
    • putLongLE

      public static void putLongLE(byte[] buf, int pos, long v)
    • putBoolean

      public static int putBoolean(byte[] bytes, int off, boolean v)
    • putBoolean

      public static int putBoolean(char[] chars, int off, boolean v)
    • isALSE

      public static boolean isALSE(byte[] buf, int pos)
    • notALSE

      public static boolean notALSE(byte[] buf, int pos)
    • isALSE

      public static boolean isALSE(char[] buf, int pos)
    • notALSE

      public static boolean notALSE(char[] buf, int pos)
    • isNULL

      public static boolean isNULL(byte[] buf, int pos)
    • notNULL

      public static boolean notNULL(byte[] buf, int pos)
    • isTRUE

      public static boolean isTRUE(byte[] buf, int pos)
    • notTRUE

      public static boolean notTRUE(byte[] buf, int pos)
    • isTRUE

      public static boolean isTRUE(char[] buf, int pos)
    • notTRUE

      public static boolean notTRUE(char[] buf, int pos)
    • isNULL

      public static boolean isNULL(char[] buf, int pos)
    • notNULL

      public static boolean notNULL(char[] buf, int pos)
    • putNULL

      public static void putNULL(byte[] buf, int pos)
    • putNULL

      public static void putNULL(char[] buf, int pos)
    • digit4

      public static int digit4(char[] chars, int off)
    • digit4

      public static int digit4(byte[] bytes, int off)
    • digit3

      public static int digit3(char[] chars, int off)
    • digit3

      public static int digit3(byte[] bytes, int off)
    • digit2

      public static int digit2(char[] chars, int off)
    • digit2

      public static int digit2(byte[] bytes, int off)
    • isDigit2

      public static boolean isDigit2(byte[] bytes, int off)
    • isDigit2

      public static boolean isDigit2(char[] bytes, int off)
    • digit

      public static int digit(int d)
    • digit1

      public static int digit1(char[] chars, int off)
    • digit1

      public static int digit1(byte[] bytes, int off)
    • indexOfQuote

      public static int indexOfQuote(byte[] value, int quote, int fromIndex, int max)
    • indexOfQuoteV

      public static int indexOfQuoteV(byte[] value, int quote, int fromIndex, int max)
    • indexOfDoubleQuote

      public static int indexOfDoubleQuote(byte[] value, int fromIndex, int max)
    • indexOfDoubleQuoteV

      public static int indexOfDoubleQuoteV(byte[] value, int fromIndex, int max)
    • indexOfLineSeparator

      public static int indexOfLineSeparator(byte[] value, int fromIndex, int max)
    • indexOfLineSeparatorV

      public static int indexOfLineSeparatorV(byte[] value, int fromIndex, int max)
    • indexOfSlash

      public static int indexOfSlash(byte[] value, int fromIndex, int max)
    • indexOfSlashV

      public static int indexOfSlashV(byte[] value, int fromIndex, int max)
    • indexOfChar

      public static int indexOfChar(byte[] value, int ch, int fromIndex, int max)
    • indexOfChar

      public static int indexOfChar(char[] value, int ch, int fromIndex, int max)
    • hexDigit4

      public static int hexDigit4(byte[] bytes, int offset)
    • hexDigit4

      public static int hexDigit4(char[] bytes, int offset)
    • isDigit

      public static boolean isDigit(int ch)
    • getShortUnaligned

      public static short getShortUnaligned(byte[] bytes, int offset)
    • getShortBE

      public static short getShortBE(byte[] bytes, int offset)
    • getShortLE

      public static short getShortLE(byte[] bytes, int offset)
    • isUTF8BOM

      public static boolean isUTF8BOM(byte[] bytes, int off)
    • getIntBE

      public static int getIntBE(byte[] bytes, int offset)
    • getIntLE

      public static int getIntLE(byte[] bytes, int offset)
    • getIntLE

      public static int getIntLE(char[] bytes, int offset)
    • getIntUnaligned

      public static int getIntUnaligned(byte[] bytes, int offset)
    • getIntUnaligned

      public static int getIntUnaligned(char[] bytes, int offset)
    • getLongBE

      public static long getLongBE(byte[] bytes, int offset)
    • getLongUnaligned

      public static long getLongUnaligned(byte[] bytes, int offset)
    • getLongUnaligned

      public static long getLongUnaligned(char[] bytes, int offset)
    • getLongLE

      public static long getLongLE(byte[] bytes, int offset)
    • getLongLE

      public static long getLongLE(char[] bytes, int offset)
    • hex2

      public static short hex2(int i)
    • hex2U

      public static short hex2U(int i)
    • utf16Hex2

      public static int utf16Hex2(int i)
    • hex4U

      public static int hex4U(int i)
    • utf16Hex4U

      public static long utf16Hex4U(long i)
    • convEndian

      public static int convEndian(boolean big, int n)
    • convEndian

      public static long convEndian(boolean big, long n)
    • isLatin1

      public static boolean isLatin1(char[] chars, int off, int len)
    • isASCII

      public static boolean isASCII(String str)
    • isASCII

      public static boolean isASCII(byte[] bytes)
    • isASCII

      public static boolean isASCII(byte[] bytes, int off, int len)
    • isNonSlashASCII

      public static boolean isNonSlashASCII(byte[] bytes, int off, int len)
    • parseInt

      public static int parseInt(byte[] bytes, int off, int len)