Class UueArchive

    • Constructor Detail

      • UueArchive

        public UueArchive()

        Initializes a new instance of the UueArchive class prepared for encoding.

        The following example shows how to uuencode file.

        
             try (UueArchive archive = new UueArchive()) {
                 archive.setSource("data.bin");
                 archive.save("archive.uue");
             }
         
      • UueArchive

        public UueArchive​(InputStream sourceStream)

        Initializes a new instance of the UueArchive class prepared for decoding.

        Open an archive from a stream and extract it to a MemoryStream

        
             ByteArrayOutputStream ms = new ByteArrayOutputStream();
             try (UueArchive archive = new UueArchive(new FileInputStream("archive.001"))) {
                 InputStream decompressed = archive.open();
                 byte[] b = new byte[8192];
                 int bytesRead;
                 while (0 < (bytesRead = decompressed.read(b, 0, b.length))) {
                     ms.write(b, 0, bytesRead);
                 }
             } catch (IOException ex) {
             }
         

        This constructor does not decode. See open() method for decompressing.

        Parameters:
        sourceStream - the source of the archive
      • UueArchive

        public UueArchive​(String path)

        Initializes a new instance of the UueArchive class.

        Open an archive from file by path and decode it to a MemoryStream

        
             ByteArrayOutputStream ms = new ByteArrayOutputStream();
             try (UueArchive archive = new UueArchive(new FileInputStream("archive.uue"))) {
                 InputStream decompressed = archive.open();
                 byte[] b = new byte[8192];
                 int bytesRead;
                 while (0 < (bytesRead = decompressed.read(b, 0, b.length))) {
                     ms.write(b, 0, bytesRead);
                 }
             } catch (IOException ex) {
             }
         

        This constructor does not decode. See open() method for decompressing.

        Parameters:
        path - the path to the archive file
        Throws:
        com.aspose.ms.System.ArgumentNullException - path is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access.
        com.aspose.ms.System.ArgumentException - The path is empty, contains only white spaces, or contains invalid characters.
        com.aspose.ms.System.IO.PathTooLongException - The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
        com.aspose.ms.System.NotSupportedException - File at path contains a colon (:) in the middle of the string.
    • Method Detail

      • getFormat

        public final ArchiveFormat getFormat()

        Gets the archive format.

        Specified by:
        getFormat in interface IArchive
        Returns:
        the archive format
      • getName

        public final String getName()

        Name of the original file.

        Specified by:
        getName in interface IArchiveFileEntry
        Returns:
        the name of the original file
      • save

        public final void save​(OutputStream outputStream)

        Saves archive to the stream provided.

        Write compressed data to http response stream.

        
             try (UueArchive archive = new UueArchive()) {
                 archive.setSource(new File("data.bin"));
                 archive.save(outputStream);
             }
         
        Parameters:
        outputStream - destination stream
        Throws:
        com.aspose.ms.System.InvalidOperationException - The source of data to be archived has not been provided.
        com.aspose.ms.System.IO.DirectoryNotFoundException - The specified file source path is invalid, such as being on an unmapped drive.
        com.aspose.ms.System.IO.IOException - The File source is already open.
      • save

        public final void save​(OutputStream outputStream,
                               UueSaveOptions saveOptions)

        Saves archive to the stream provided.

        Write compressed data to http response stream.

        
             try (UueArchive archive = new UueArchive()) {
                 archive.setSource(new File("data.bin"));
                 archive.save(outputStream);
             }
         
        Parameters:
        outputStream - destination stream
        saveOptions - options for the archive saving
        Throws:
        com.aspose.ms.System.InvalidOperationException - The source of data to be archived has not been provided.
        com.aspose.ms.System.IO.DirectoryNotFoundException - The specified file source path is invalid, such as being on an unmapped drive.
        com.aspose.ms.System.IO.IOException - The File source is already open.
      • save

        public final void save​(String destinationFileName)

        Saves the archive to the destination file provided.

        Write encoded data to file.

        
             try (UueArchive archive = new UueArchive()) {
                 archive.setSource(new File("data.bin"));
                 archive.save("data.uue");
             }
         
        Parameters:
        destinationFileName - the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
        Throws:
        com.aspose.ms.System.ArgumentNullException - destinationFileName is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access.
        com.aspose.ms.System.ArgumentException - The destinationFileName is empty, contains only white spaces, or contains invalid characters.
        com.aspose.ms.System.IO.PathTooLongException - The specified destinationFileName, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
        com.aspose.ms.System.NotSupportedException - File at destinationFileName contains a colon (:) in the middle of the string.
      • save

        public final void save​(String destinationFileName,
                               UueSaveOptions saveOptions)

        Saves the archive to the destination file provided.

        Write encoded data to file.

        
             try (UueArchive archive = new UueArchive()) {
                 archive.setSource(new File("data.bin"));
                 archive.save("data.uue");
             }
         
        Parameters:
        destinationFileName - the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
        saveOptions - options for the archive saving
        Throws:
        com.aspose.ms.System.ArgumentNullException - destinationFileName is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access.
        com.aspose.ms.System.ArgumentException - The destinationFileName is empty, contains only white spaces, or contains invalid characters.
        com.aspose.ms.System.IO.PathTooLongException - The specified destinationFileName, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
        com.aspose.ms.System.NotSupportedException - File at destinationFileName contains a colon (:) in the middle of the string.
      • extract

        public final void extract​(OutputStream destination)

        Extracts the archive to the stream provided.

        
             try (UueArchive archive = new UueArchive("archive.uue")) {
                 archive.extract(httpResponseStream);
             }
         
        Specified by:
        extract in interface IArchiveFileEntry
        Parameters:
        destination - destination stream
      • extract

        public final File extract​(String path)

        Extracts the archive to the file by path.

        Specified by:
        extract in interface IArchiveFileEntry
        Parameters:
        path - the path to destination file. If the file already exists, it will be overwritten
        Returns:
        info of the extracted file
        Throws:
        com.aspose.ms.System.ArgumentNullException - path is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access.
        com.aspose.ms.System.ArgumentException - The path is empty, contains only white spaces, or contains invalid characters.
        com.aspose.ms.System.IO.PathTooLongException - The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
        com.aspose.ms.System.NotSupportedException - File at path contains a colon (:) in the middle of the string.
        com.aspose.ms.System.IO.FileNotFoundException - The file is not found.
        com.aspose.ms.System.IO.DirectoryNotFoundException - The specified path is invalid, such as being on an unmapped drive.
        com.aspose.ms.System.IO.IOException - The file is already open.
      • extractToDirectory

        public final void extractToDirectory​(String destinationDirectory)

        Extracts content of the archive to the directory provided.

        Specified by:
        extractToDirectory in interface IArchive
        Parameters:
        destinationDirectory - the path to the directory to place the extracted files in.

        If the directory does not exist, it will be created

        Throws:
        com.aspose.ms.System.ArgumentNullException - destinationDirectory is null.
        com.aspose.ms.System.IO.PathTooLongException - The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters and file names must be less than 260 characters.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access the existing directory.
        com.aspose.ms.System.NotSupportedException - If the directory does not exist, the path contains a colon character (:) that is not part of a drive label ("C:\").
        com.aspose.ms.System.ArgumentException - destinationDirectory is a zero-length string, contains only white space, or contains one or more invalid characters.
        com.aspose.ms.System.IO.IOException - The directory specified by path is a file. -or- The network name is not known.
      • open

        public final InputStream open()

        Opens the archive for decoding and provides a stream with archive content.

        Usage:
        
             try (InputStream decompressed = archive.open()) {
                 byte[] buffer = new byte[8192];
                 int bytesRead;
                 while (0 < (bytesRead = decompressed.read(buffer, 0, buffer.length))) {
                     fileStream.write(buffer, 0, bytesRead);
                 }
             } catch (IOException ex) {
             }
         

        Read from the stream to get the original content of the file. See examples section.

        Returns:
        the stream that represents the contents of the archive
      • setSource

        public final void setSource​(InputStream source)

        Sets the content to be encoded within the archive.

        
             try (UueArchive archive = new UueArchive()) {
                 archive.setSource(new ByteArrayInputStream(new byte[] {
                         0x00,
                         (byte) 0xFF
                 }));
                 archive.save("archive.uue");
             }
         
        Parameters:
        source - the input stream for the archive
      • setSource

        public final void setSource​(File file)

        Sets the content to be compressed within the archive.

        
             try (UueArchive archive = new UueArchive()) {
                 archive.setSource(new File("data.bin"));
                 archive.save("archive.uue");
             }
         
        Parameters:
        file - the reference to a file to be compressed
      • setSource

        public final void setSource​(String path)

        Sets the content to be encoded within the archive.

        
             try (UueArchive archive = new UueArchive()) {
                 archive.setSource("data.bin");
                 archive.save("archive.uue");
             }
         
        Parameters:
        path - path to file to be encoded
        Throws:
        com.aspose.ms.System.ArgumentNullException - path is null.
        com.aspose.ms.System.SecurityException - The caller does not have the required permission to access.
        com.aspose.ms.System.ArgumentException - The path is empty, contains only white spaces, or contains invalid characters.
        com.aspose.ms.System.IO.PathTooLongException - The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
        com.aspose.ms.System.NotSupportedException - File at path contains a colon (:) in the middle of the string.