Interface Resource

    • Method Detail

      • openInputStream

        java.io.InputStream openInputStream()
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • write

        void write​(java.io.OutputStream out)
            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • write

        default void write​(java.io.File file)
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • write

        default void write​(java.nio.file.Path path)
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • lastModified

        long lastModified()
      • setExtra

        void setExtra​(java.lang.String extra)
        Use encodeExtra(byte[]) to properly encode the ZIP extra field structured binary data into the specified String.
        Parameters:
        extra - A String encoding the ZIP extra field.
      • getExtra

        java.lang.String getExtra()
        Use decodeExtra(String) to properly decode the ZIP extra field structured binary data from the returned String.
        Returns:
        A String encoding the ZIP extra field.
      • size

        long size()
           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • buffer

        java.nio.ByteBuffer buffer()
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • fromURL

        static Resource fromURL​(java.net.URL url)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • fromURL

        static Resource fromURL​(java.net.URL url,
                                HttpClient client)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • encodeExtra

        static java.lang.String encodeExtra​(byte[] extra)
        Encode the ZIP extra field as a String.

        Since the Resource API uses a String as the storage format for the extra field and the extra field is structured binary data, we encode the byte array as a char array in a String. Since the byte array can have an odd length, we must also encode the array length so that we can decode into the correct byte array length.

        Parameters:
        extra - A ZIP extra field.
        Returns:
        A String encoding of the specified ZIP extra field.
        See Also:
        Section 4.5 - Extensible data fields
      • decodeExtra

        static byte[] decodeExtra​(java.lang.String encoded)
        Decode a String to a ZIP extra field.

        Since the Resource API uses a String as the storage format for the extra field and the extra field is structured binary data, we encode the byte array as a char array in a String. Since the byte array can have an odd length, we must also encode the array length so that we can decode into the correct byte array length.

        Parameters:
        encoded - A String encoding of the ZIP extra field.
        Returns:
        The ZIP extra field encoded in the specified string.
        See Also:
        Section 4.5 - Extensible data fields