Class TarOutputStream

All Implemented Interfaces:
AutoCloseable

public class TarOutputStream extends BufferedOutputStream
  • Field Summary

    Fields inherited from class BufferedOutputStream

    buf, count
    Modifier and Type
    Field
    Description
    protected byte[]
    The internal buffer where data is stored.
    protected int
    The number of valid bytes in the buffer.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Appends the EOF record and closes the stream
    protected void
    Closes the current tar entry
    protected void
    pad()
    Pads the last content block
    void
    Writes the next tar entry header on the stream
    void
    write(byte[] b, int off, int len)
    Checks if the bytes being written exceed the current entry size.
    void
    write(int b)
    Writes a byte to the stream and updates byte counters

    Methods inherited from class BufferedOutputStream

    flush, flushBuffer, getConnection, getDefaultBufferSize, getLastActivityTime, getName, getTotalBytesWritten, setConnection, setDefaultBufferSize, setProgressListener, write
    Modifier and Type
    Method
    Description
    void
    Flushes this buffered output stream.
    void
    Flush the internal buffer
    If applicable this member represents the connection object for the stream
    static int
    The default size for a stream buffer
    long
    Returns the time of the last activity
    Indicates the name of the stream for debugging purposes
    int
    Returns the total amount of bytes written to this stream so far
    void
    setConnection(Object connection)
    If applicable this member represents the connection object for the stream
    static void
    setDefaultBufferSize(int aDefaultBufferSize)
    The default size for a stream buffer
    void
    Sets the callback for IO updates from a buffered stream
    void
    write(byte[] b)
    Writes b.length bytes to this output stream.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
     
    boolean
    Indicates whether some other object is "equal to" this one.
    final Class
    Returns the runtime class of an object.
    int
    Returns a hash code value for the object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
  • Constructor Details

    • TarOutputStream

      public TarOutputStream(OutputStream out)
  • Method Details

    • close

      public void close() throws IOException

      Appends the EOF record and closes the stream

      See also
      • java.io.FilterOutputStream#close()
      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class BufferedOutputStream
      Throws:
      IOException
    • write

      public void write(int b) throws IOException

      Writes a byte to the stream and updates byte counters

      See also
      • java.io.FilterOutputStream#write(int)
      Overrides:
      write in class BufferedOutputStream
      Throws:
      IOException
    • write

      public void write(byte[] b, int off, int len) throws IOException

      Checks if the bytes being written exceed the current entry size.

      See also
      • java.io.FilterOutputStream#write(byte[], int, int)
      Overrides:
      write in class BufferedOutputStream
      Throws:
      IOException
    • putNextEntry

      public void putNextEntry(TarEntry entry) throws IOException

      Writes the next tar entry header on the stream

      Parameters
      • entry
      Throws
      • IOException
      Throws:
      IOException
    • closeCurrentEntry

      protected void closeCurrentEntry() throws IOException

      Closes the current tar entry

      Throws
      • IOException
      Throws:
      IOException
    • pad

      protected void pad() throws IOException

      Pads the last content block

      Throws
      • IOException
      Throws:
      IOException