Package org.apache.commons.imaging.bytesource

# Class ByteSource

java.lang.Object
org.apache.commons.imaging.bytesource.ByteSource

public class ByteSource extends Object

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ByteSource`
  `array(byte[] array)`
  `static ByteSource`
  `array(byte[] array, String name)`
  `static ByteSource`
  `file(File file)`
  `byte[]`
  `getByteArray(long position, int length)`
  `final String`
  `getFileName()`
  `InputStream`
  `getInputStream()`
  `static final InputStream`
  `getInputStream(ByteSource byteSource, long skip)`
  `static ByteSource`
  `inputStream(InputStream is, String name)`
  `static ByteSource`
  `path(Path file)`
  `long`
  `size()`
  This operation can be VERY expensive; for InputStream byte sources, the entire stream must be drained to determine its length.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Method Details

  - ### array

    public static ByteSource array(byte[] array)

  - ### array

    public static ByteSource array(byte[] array, String name)

  - ### file

    public static ByteSource file(File file)

  - ### getInputStream

    public static final InputStream getInputStream(ByteSource byteSource, long skip) throws IOException
    Throws:
      `IOException`

  - ### inputStream

    public static ByteSource inputStream(InputStream is, String name) throws IOException
    Throws:
      `IOException`

  - ### path

    public static ByteSource path(Path file)

  - ### getByteArray

    public byte[] getByteArray(long position, int length) throws IOException
    Throws:
      `IOException`

  - ### getFileName

    public final String getFileName()

  - ### getInputStream

    public InputStream getInputStream() throws IOException
    Throws:
      `IOException`

  - ### size

    public long size() throws 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:
      `IOException` - if it fails to read the byte source data

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`