Class ByteData


  • public class ByteData
    extends java.lang.Object
    ByteData
    thread-non-safe :
    Be sure to use it in a single thread.
    Since:
    3.0
    Author:
    PARK Yong Seo
    • Method Summary

      Modifier and Type Method Description
      ByteData bind​(java.io.OutputStream os)
      bind all data to output stream
      ByteData bind​(java.io.OutputStream os, int limit)
      bind all data to output stream
      static ByteData create()
      create
      capacity : 8192
      static ByteData create​(int capacity, java.lang.String charset)
      create
      capacity : 8192
      static ByteData create​(java.lang.String charset)
      create
      capacity : 8192
      ByteData fillSpace()
      null bytes fill the spaces char
      [0 0 0 0 97 (writePointer)0 0 0]
      fillSpace()
      [32 32 32 32 97 (writePointer)0 0 0]
      ByteData insert​(byte[] data, int offset)
      insert
      does not move write pointer
      ByteData insert​(byte[] data, int dataOffset, int dataLength, int offset)
      insert
      does not move write pointer
      ByteData insert​(java.lang.String data, int offset)
      insert
      does not move write pointer
      ByteData insertFill​(byte fill, int offset, int length)
      insert fill
      ByteData insertFillSpace​(int offset, int length)
      insert fill space
      ByteData insertFixed​(java.lang.String data, int fixedSize, byte fill, int offset)
      insert fixed data
      ByteData insertFixedAlignRight​(java.lang.String data, int fixedSize, byte fill, int offset)
      insert fixed data
      ByteData moveWritePointer​(int index)
      move the write pointer (next write index pointer)
      moveWritePointer(3) : next write index point 3, length 2
      ByteData newByteData​(int offset, int length)
      new ByteData
      byte[] read​(int size)
      read
      ByteData readIgnore​(int size)
      read ignore
      ByteData readIgnoreCurrentLine()
      move read pointer to next line
      ByteData readIgnoreMatch​(byte match)
      read ignore
      java.lang.String readText​(int size, boolean isEmptyToNull)
      read text
      java.lang.String readTextAlignRight​(int size, boolean isEmptyToNull)
      read text
      int readTextInt​(int size, int emptyDefaultValue)
      read text int
      long readTextLong​(int size, long emptyDefaultValue)
      read text long
      ByteData rectifyWritePointer()
      rectify the write pointer (next write index pointer)
      create and insert method and to String is ""
      because insert method is not moving write pointer
      this method is moving pointer last data of buffer
      ex) create
      [0 0 0 0 0 0 0 0] / write pointer:0
      insert("a", 3); [0 0 0 97 0 0 0 0] / write pointer:0
      rectifyWritePointer();
      [0 0 0 97 0 0 0 0] / write pointer:4
      int size()
      data size
      byte[] toBytes()
      to bytes
      byte[] toBytes​(int offset, int length)
      to bytes
      java.lang.String toString()
      to string
      ByteData write​(byte[] data)
      write data
      ByteData write​(byte[] data, int offset, int length)
      write data
      ByteData write​(java.io.File file)
      write file input stream
      ByteData write​(java.io.File file, java.lang.String fileCharset)
      write file input stream
      ByteData write​(java.io.InputStream is)
      write inputstream
      inputstream will not be closed
      ByteData write​(java.io.InputStream is, int limit)
      write inputstream
      inputstream will not be closed
      ByteData write​(java.lang.String data)
      write data
      ByteData writeFill​(byte fill, int length)
      write fill
      ByteData writeFillSpace​(int length)
      write fill space
      ByteData writeFixed​(int data, int fixedSize, byte fill)
      write fixed size
      ByteData writeFixed​(java.lang.String data, int fixedSize, byte fill)
      write fixed size
      ByteData writeFixedAlignRight​(int data, int fixedSize, byte fill)
      write fixed size
      ByteData writeFixedAlignRight​(java.lang.String data, int fixedSize, byte fill)
      write fixed size
      ByteData writeLine1()
      write \n
      ByteData writeLine2()
      write \r\n
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • create

        public static ByteData create()
        create
        capacity : 8192
        Returns:
      • create

        public static ByteData create​(java.lang.String charset)
        create
        capacity : 8192
        Parameters:
        charset -
        Returns:
      • create

        public static ByteData create​(int capacity,
                                      java.lang.String charset)
        create
        capacity : 8192
        Parameters:
        capacity -
        charset -
        Returns:
      • write

        public ByteData write​(byte[] data,
                              int offset,
                              int length)
        write data
        Parameters:
        data -
        offset -
        length -
        Returns:
      • write

        public ByteData write​(byte[] data)
        write data
        Parameters:
        data -
        Returns:
      • write

        public ByteData write​(java.lang.String data)
                       throws java.io.IOException
        write data
        Parameters:
        data -
        Returns:
        Throws:
        java.io.IOException
      • writeFixed

        public ByteData writeFixed​(java.lang.String data,
                                   int fixedSize,
                                   byte fill)
                            throws java.io.IOException
        write fixed size
        Parameters:
        data -
        fixedSize -
        fill -
        Returns:
        Throws:
        java.io.IOException
      • writeFixed

        public ByteData writeFixed​(int data,
                                   int fixedSize,
                                   byte fill)
                            throws java.io.IOException
        write fixed size
        Parameters:
        data -
        fixedSize -
        fill -
        Returns:
        Throws:
        java.io.IOException
      • writeFixedAlignRight

        public ByteData writeFixedAlignRight​(java.lang.String data,
                                             int fixedSize,
                                             byte fill)
                                      throws java.io.IOException
        write fixed size
        Parameters:
        data -
        fixedSize -
        fill -
        Returns:
        Throws:
        java.io.IOException
      • writeFixedAlignRight

        public ByteData writeFixedAlignRight​(int data,
                                             int fixedSize,
                                             byte fill)
                                      throws java.io.IOException
        write fixed size
        Parameters:
        data -
        fixedSize -
        fill -
        Returns:
        Throws:
        java.io.IOException
      • write

        public ByteData write​(java.io.InputStream is)
                       throws java.io.IOException
        write inputstream
        inputstream will not be closed
        Parameters:
        is -
        Returns:
        Throws:
        java.io.IOException
      • write

        public ByteData write​(java.io.InputStream is,
                              int limit)
                       throws java.io.IOException
        write inputstream
        inputstream will not be closed
        Parameters:
        is -
        limit - input stream stop size
        Returns:
        Throws:
        java.io.IOException
      • write

        public ByteData write​(java.io.File file)
                       throws java.io.IOException
        write file input stream
        Parameters:
        file -
        Returns:
        Throws:
        java.io.IOException
      • write

        public ByteData write​(java.io.File file,
                              java.lang.String fileCharset)
                       throws java.io.IOException
        write file input stream
        Parameters:
        file -
        fileCharset -
        Returns:
        Throws:
        java.io.IOException
      • insert

        public ByteData insert​(byte[] data,
                               int dataOffset,
                               int dataLength,
                               int offset)
        insert
        does not move write pointer
        Parameters:
        data -
        dataOffset -
        dataLength -
        offset -
        Returns:
      • insert

        public ByteData insert​(byte[] data,
                               int offset)
        insert
        does not move write pointer
        Parameters:
        data -
        offset -
        Returns:
      • insert

        public ByteData insert​(java.lang.String data,
                               int offset)
                        throws java.io.IOException
        insert
        does not move write pointer
        Parameters:
        data -
        offset -
        Returns:
        Throws:
        java.io.IOException
      • insertFixed

        public ByteData insertFixed​(java.lang.String data,
                                    int fixedSize,
                                    byte fill,
                                    int offset)
                             throws java.io.IOException
        insert fixed data
        Parameters:
        data -
        fixedSize -
        fill -
        ALIGN -
        offset -
        Returns:
        Throws:
        java.io.IOException
      • insertFixedAlignRight

        public ByteData insertFixedAlignRight​(java.lang.String data,
                                              int fixedSize,
                                              byte fill,
                                              int offset)
                                       throws java.io.IOException
        insert fixed data
        Parameters:
        data -
        fixedSize -
        fill -
        ALIGN -
        offset -
        Returns:
        Throws:
        java.io.IOException
      • insertFill

        public ByteData insertFill​(byte fill,
                                   int offset,
                                   int length)
        insert fill
        Parameters:
        fill -
        offset -
        length -
        Returns:
      • insertFillSpace

        public ByteData insertFillSpace​(int offset,
                                        int length)
        insert fill space
        Parameters:
        offset -
        length -
        Returns:
      • writeFill

        public ByteData writeFill​(byte fill,
                                  int length)
        write fill
        Parameters:
        fill -
        length -
        Returns:
      • writeFillSpace

        public ByteData writeFillSpace​(int length)
        write fill space
        Parameters:
        length -
        Returns:
      • moveWritePointer

        public ByteData moveWritePointer​(int index)
        move the write pointer (next write index pointer)
        moveWritePointer(3) : next write index point 3, length 2
        Parameters:
        index -
        Returns:
      • rectifyWritePointer

        public ByteData rectifyWritePointer()
        rectify the write pointer (next write index pointer)
        create and insert method and to String is ""
        because insert method is not moving write pointer
        this method is moving pointer last data of buffer
        ex) create
        [0 0 0 0 0 0 0 0] / write pointer:0
        insert("a", 3); [0 0 0 97 0 0 0 0] / write pointer:0
        rectifyWritePointer();
        [0 0 0 97 0 0 0 0] / write pointer:4
        Returns:
      • fillSpace

        public ByteData fillSpace()
        null bytes fill the spaces char
        [0 0 0 0 97 (writePointer)0 0 0]
        fillSpace()
        [32 32 32 32 97 (writePointer)0 0 0]
        Returns:
      • writeLine1

        public ByteData writeLine1()
        write \n
        Returns:
      • writeLine2

        public ByteData writeLine2()
        write \r\n
        Returns:
      • bind

        public ByteData bind​(java.io.OutputStream os)
                      throws java.io.IOException
        bind all data to output stream
        Parameters:
        os -
        Returns:
        Throws:
        java.io.IOException
      • bind

        public ByteData bind​(java.io.OutputStream os,
                             int limit)
                      throws java.io.IOException
        bind all data to output stream
        Parameters:
        os -
        limit -
        Returns:
        Throws:
        java.io.IOException
      • read

        public byte[] read​(int size)
                    throws java.io.IOException
        read
        Parameters:
        size -
        Returns:
        Throws:
        java.io.IOException
      • readText

        public java.lang.String readText​(int size,
                                         boolean isEmptyToNull)
                                  throws java.io.IOException
        read text
        Parameters:
        size -
        isEmptyToNull -
        Returns:
        Throws:
        java.io.IOException
      • readTextAlignRight

        public java.lang.String readTextAlignRight​(int size,
                                                   boolean isEmptyToNull)
                                            throws java.io.IOException
        read text
        Parameters:
        size -
        isEmptyToNull -
        Returns:
        Throws:
        java.io.IOException
      • readTextInt

        public int readTextInt​(int size,
                               int emptyDefaultValue)
                        throws java.io.IOException
        read text int
        Parameters:
        size -
        emptyDefaultValue -
        Returns:
        Throws:
        java.io.IOException
      • readTextLong

        public long readTextLong​(int size,
                                 long emptyDefaultValue)
                          throws java.io.IOException
        read text long
        Parameters:
        size -
        emptyDefaultValue -
        Returns:
        Throws:
        java.io.IOException
      • readIgnore

        public ByteData readIgnore​(int size)
        read ignore
        Parameters:
        size -
        Returns:
      • readIgnoreMatch

        public ByteData readIgnoreMatch​(byte match)
                                 throws java.io.IOException
        read ignore
        Parameters:
        match -
        Returns:
        Throws:
        java.io.IOException
      • readIgnoreCurrentLine

        public ByteData readIgnoreCurrentLine()
                                       throws java.io.IOException
        move read pointer to next line
        Returns:
        Throws:
        java.io.IOException
      • newByteData

        public ByteData newByteData​(int offset,
                                    int length)
        new ByteData
        Parameters:
        offset -
        length -
        Returns:
      • size

        public int size()
        data size
        Returns:
      • toString

        public java.lang.String toString()
        to string
        Overrides:
        toString in class java.lang.Object
      • toBytes

        public byte[] toBytes()
        to bytes
        Returns:
      • toBytes

        public byte[] toBytes​(int offset,
                              int length)
        to bytes
        Parameters:
        offset -
        length -
        Returns: