Class Pack200UnpackerAdapter

  • All Implemented Interfaces:
    Pack200.Unpacker

    public class Pack200UnpackerAdapter
    extends Pack200Adapter
    implements Pack200.Unpacker
    This class provides the binding between the standard Pack200 interface and the internal interface for (un)packing.
    • Constructor Detail

      • Pack200UnpackerAdapter

        public Pack200UnpackerAdapter()
    • Method Detail

      • newBoundedInputStream

        static BoundedInputStream newBoundedInputStream​(java.io.File file)
                                                 throws java.io.IOException
        Creates a new BoundedInputStream bound by the size of the given file.

        The new BoundedInputStream wraps a new BufferedInputStream.

        Parameters:
        file - The file.
        Returns:
        a new BoundedInputStream
        Throws:
        java.io.IOException - if an I/O error occurs
      • newBoundedInputStream

        private static BoundedInputStream newBoundedInputStream​(java.io.FileInputStream fileInputStream)
                                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • newBoundedInputStream

        static BoundedInputStream newBoundedInputStream​(java.io.InputStream inputStream)
                                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • newBoundedInputStream

        static BoundedInputStream newBoundedInputStream​(java.nio.file.Path path)
                                                 throws java.io.IOException
        Creates a new BoundedInputStream bound by the size of the given path.

        The new BoundedInputStream wraps a new BufferedInputStream.

        Parameters:
        path - The path.
        Returns:
        a new BoundedInputStream
        Throws:
        java.io.IOException - if an I/O error occurs
      • newBoundedInputStream

        static BoundedInputStream newBoundedInputStream​(java.lang.String first,
                                                        java.lang.String... more)
                                                 throws java.io.IOException
        Creates a new BoundedInputStream bound by the size of the given file.

        The new BoundedInputStream wraps a new BufferedInputStream.

        Parameters:
        first - the path string or initial part of the path string.
        more - additional strings to be joined to form the path string.
        Returns:
        a new BoundedInputStream
        Throws:
        java.io.IOException - if an I/O error occurs
      • newBoundedInputStream

        static BoundedInputStream newBoundedInputStream​(java.net.URL url)
                                                 throws java.io.IOException,
                                                        java.net.URISyntaxException
        Creates a new BoundedInputStream bound by the size of the given URL to a file.

        The new BoundedInputStream wraps a new BufferedInputStream.

        Parameters:
        url - The URL.
        Returns:
        a new BoundedInputStream
        Throws:
        java.io.IOException - if an I/O error occurs
        java.net.URISyntaxException
      • readField

        private static <T> T readField​(java.lang.Object target,
                                       java.lang.Class<?> cls,
                                       java.lang.String fieldName)
      • readPathString

        static java.lang.String readPathString​(java.io.FileInputStream fis)
      • unwrap

        static java.io.InputStream unwrap​(java.io.FilterInputStream filterInputStream)
        Unwraps the given FilterInputStream to return its wrapped InputStream.
        Parameters:
        filterInputStream - The FilterInputStream to unwrap.
        Returns:
        The wrapped InputStream
      • unwrap

        static java.io.InputStream unwrap​(java.io.InputStream inputStream)
        Unwraps the given InputStream if it is an FilterInputStream to return its wrapped InputStream.
        Parameters:
        inputStream - The FilterInputStream to unwrap.
        Returns:
        The wrapped InputStream
      • unpack

        public void unpack​(java.io.File file,
                           java.util.jar.JarOutputStream out)
                    throws java.io.IOException
        Description copied from interface: Pack200.Unpacker
        Unpacks the contents of the specified File to the specified JAR output stream.
        Specified by:
        unpack in interface Pack200.Unpacker
        Parameters:
        file - file to uncompress.
        out - JAR output stream of uncompressed data.
        Throws:
        java.io.IOException - if I/O exception occurs.
      • unpack

        public void unpack​(java.io.InputStream in,
                           java.util.jar.JarOutputStream out)
                    throws java.io.IOException
        Description copied from interface: Pack200.Unpacker
        Unpacks the specified stream to the specified JAR output stream.
        Specified by:
        unpack in interface Pack200.Unpacker
        Parameters:
        in - stream to uncompress, preferably a BoundedInputStream.
        out - JAR output stream of uncompressed data.
        Throws:
        java.io.IOException - if I/O exception occurs.