Class ByteSource

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String fileName  
      private org.apache.commons.io.build.AbstractOrigin<?,​?> origin  
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteSource​(org.apache.commons.io.build.AbstractOrigin<?,​?> origin, java.lang.String fileName)  
    • Field Detail

      • fileName

        private final java.lang.String fileName
      • origin

        private final org.apache.commons.io.build.AbstractOrigin<?,​?> origin
    • Constructor Detail

      • ByteSource

        ByteSource​(org.apache.commons.io.build.AbstractOrigin<?,​?> origin,
                   java.lang.String fileName)
    • Method Detail

      • array

        public static ByteSource array​(byte[] array)
      • array

        public static ByteSource array​(byte[] array,
                                       java.lang.String name)
      • file

        public static ByteSource file​(java.io.File file)
      • getInputStream

        public static final java.io.InputStream getInputStream​(ByteSource byteSource,
                                                               long skip)
                                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • inputStream

        public static ByteSource inputStream​(java.io.InputStream is,
                                             java.lang.String name)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • path

        public static ByteSource path​(java.nio.file.Path file)
      • getByteArray

        public byte[] getByteArray​(long position,
                                   int length)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • getFileName

        public final java.lang.String getFileName()
      • getInputStream

        public java.io.InputStream getInputStream()
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • size

        public long size()
                  throws java.io.IOException
        This operation can be VERY expensive; for InputStream byte sources, the entire stream must be drained to determine its length.
        Returns:
        the byte source length
        Throws:
        java.io.IOException - if it fails to read the byte source data
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object