Class BytesOf

  • All Implemented Interfaces:
    Bytes

    public final class BytesOf
    extends Object
    implements Bytes
    A Bytes that encapsulates other sources of data.

    There is no thread-safety guarantee.

    Since:
    0.12
    • Constructor Detail

      • BytesOf

        public BytesOf​(Input input)
        Ctor.
        Parameters:
        input - The input
      • BytesOf

        public BytesOf​(InputStream input)
        Ctor.
        Parameters:
        input - The input
        Since:
        0.29.2
      • BytesOf

        public BytesOf​(File file)
        Ctor.
        Parameters:
        file - The input
        Since:
        0.13
      • BytesOf

        public BytesOf​(Path path)
        Ctor.
        Parameters:
        path - The input
        Since:
        0.13
      • BytesOf

        public BytesOf​(Input input,
                       int max)
        Ctor.
        Parameters:
        input - The input
        max - Max length of the buffer for reading
      • BytesOf

        public BytesOf​(Reader rdr)
        Ctor.
        Parameters:
        rdr - Reader
      • BytesOf

        public BytesOf​(Reader rdr,
                       Charset charset)
        Ctor.
        Parameters:
        rdr - Reader
        charset - Charset
      • BytesOf

        public BytesOf​(Reader rdr,
                       CharSequence charset)
        Ctor.
        Parameters:
        rdr - Reader
        charset - Charset
      • BytesOf

        public BytesOf​(Reader rdr,
                       Charset charset,
                       int max)
        Ctor.
        Parameters:
        rdr - Reader
        charset - Charset
        max - Buffer size
      • BytesOf

        public BytesOf​(Reader rdr,
                       int max)
        Ctor.
        Parameters:
        rdr - Reader
        max - Buffer size
        Since:
        0.13.3
      • BytesOf

        public BytesOf​(Reader rdr,
                       CharSequence charset,
                       int max)
        Ctor.
        Parameters:
        rdr - Reader
        charset - Charset
        max - Buffer size
      • BytesOf

        public BytesOf​(CharSequence input)
        Ctor.
        Parameters:
        input - The source
      • BytesOf

        public BytesOf​(CharSequence input,
                       Charset charset)
        Ctor.
        Parameters:
        input - The source
        charset - The charset
      • BytesOf

        public BytesOf​(CharSequence input,
                       CharSequence charset)
        Ctor.
        Parameters:
        input - The source
        charset - The charset
      • BytesOf

        public BytesOf​(char... chars)
        Ctor.
        Parameters:
        chars - The chars
      • BytesOf

        public BytesOf​(char[] chars,
                       Charset charset)
        Ctor.
        Parameters:
        chars - The chars
        charset - The charset
      • BytesOf

        public BytesOf​(char[] chars,
                       CharSequence charset)
        Ctor.
        Parameters:
        chars - The chars
        charset - The charset
      • BytesOf

        public BytesOf​(Text text)
        Ctor.
        Parameters:
        text - The source
      • BytesOf

        public BytesOf​(Text text,
                       Charset charset)
        Ctor.
        Parameters:
        text - The source
        charset - The charset
      • BytesOf

        public BytesOf​(Text text,
                       CharSequence charset)
        Ctor.
        Parameters:
        text - The source
        charset - The charset
      • BytesOf

        public BytesOf​(Throwable error)
        Ctor.
        Parameters:
        error - The exception to serialize
      • BytesOf

        public BytesOf​(Throwable error,
                       Charset charset)
        Ctor.
        Parameters:
        error - The exception to serialize
        charset - Charset
      • BytesOf

        public BytesOf​(Throwable error,
                       CharSequence charset)
        Ctor.
        Parameters:
        error - The exception to serialize
        charset - Charset
      • BytesOf

        public BytesOf​(StackTraceElement... strace)
        Ctor.
        Parameters:
        strace - The stack trace
        Since:
        0.29
      • BytesOf

        public BytesOf​(StackTraceElement[] strace,
                       Charset charset)
        Ctor.
        Parameters:
        strace - The stack trace
        charset - Charset
        Since:
        0.29
      • BytesOf

        public BytesOf​(StackTraceElement[] strace,
                       CharSequence charset)
        Ctor.
        Parameters:
        strace - The stack trace
        charset - Charset
        Since:
        0.29
      • BytesOf

        public BytesOf​(byte... bytes)
        Ctor.
        Parameters:
        bytes - Bytes to encapsulate
      • BytesOf

        public BytesOf​(Iterator<Byte> iterator)
        Ctor.
        Parameters:
        iterator - Iterator of bytes
      • BytesOf

        public BytesOf​(Iterable<Byte> bytes)
        Ctor.
        Parameters:
        bytes - Iterable of bytes
      • BytesOf

        public BytesOf​(Collection<Byte> bytes)
        Ctor.
        Parameters:
        bytes - Collection of bytes
    • Method Detail

      • asBytes

        public byte[] asBytes()
                       throws Exception
        Description copied from interface: Bytes
        Convert it to the byte array.
        Specified by:
        asBytes in interface Bytes
        Returns:
        The byte array
        Throws:
        Exception - If fails