UueArchive

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.zip.IArchive, com.aspose.zip.IArchiveFileEntry, java.lang.AutoCloseable

public class UueArchive implements IArchive, IArchiveFileEntry, AutoCloseable

This class represents uuencoded file.

Constructors

ConstructorDescription
UueArchive()Initializes a new instance of the UueArchive class prepared for encoding.
UueArchive(InputStream sourceStream)Initializes a new instance of the UueArchive class prepared for decoding.
UueArchive(String path)Initializes a new instance of the UueArchive class.

Methods

MethodDescription
close(){@inheritDoc}
extract(OutputStream destination)Extracts the archive to the stream provided.
extract(String path)Extracts the archive to the file by path.
extractToDirectory(String destinationDirectory)Extracts content of the archive to the directory provided.
getFileEntries()Gets entries of IArchiveFileEntry type constituting the uue archive.
getLength()Gets length.
getName()Name of original file.
open()Opens the archive for decoding and provides a stream with archive content.
save(OutputStream outputStream)Saves archive to the stream provided.
save(OutputStream outputStream, UueSaveOptions saveOptions)Saves archive to the stream provided.
save(String destinationFileName)Saves the archive to destination file provided.
save(String destinationFileName, UueSaveOptions saveOptions)Saves the archive to the destination file provided.
setSource(File file)Sets the content to be compressed within the archive.
setSource(InputStream source)Sets the content to be encoded within the archive.
setSource(String path)Sets the content to be encoded within the archive.

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(InputStream sourceStream)

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:

ParameterTypeDescription
sourceStreamjava.io.InputStreamthe source of the archive

UueArchive(String path)

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:

ParameterTypeDescription
pathjava.lang.Stringthe path to the archive file

close()

public void close()

extract(OutputStream destination)

public final void extract(OutputStream destination)

Extracts the archive to the stream provided.


     try (UueArchive archive = new UueArchive("archive.uue")) {
         archive.extract(httpResponseStream);
     }
 

Parameters:

ParameterTypeDescription
destinationjava.io.OutputStreamdestination stream

extract(String path)

public final File extract(String path)

Extracts the archive to the file by path.

Parameters:

ParameterTypeDescription
pathjava.lang.Stringthe path to destination file. If the file already exists, it will be overwritten

Returns: java.io.File - info of extracted file

extractToDirectory(String destinationDirectory)

public final void extractToDirectory(String destinationDirectory)

Extracts content of the archive to the directory provided.

Parameters:

ParameterTypeDescription
destinationDirectoryjava.lang.Stringthe path to the directory to place the extracted files in.

If the directory does not exist, it will be created |

getFileEntries()

public final Iterable<IArchiveFileEntry> getFileEntries()

Gets entries of IArchiveFileEntry type constituting the uue archive.

Returns: java.lang.Iterable<com.aspose.zip.IArchiveFileEntry> - entries of IArchiveFileEntry type constituting the uue archive

getLength()

public final Long getLength()

Gets length.

Returns: java.lang.Long - length

getName()

public final String getName()

Name of original file.

Returns: java.lang.String - the name of the original file

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 original content of file. See examples section.

Returns: java.io.InputStream - the stream that represents the contents of the archive

save(OutputStream outputStream)

public final void save(OutputStream outputStream)

Saves archive to the stream provided.

Writes compressed data to http response stream.


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

Parameters:

ParameterTypeDescription
outputStreamjava.io.OutputStreamdestination stream

save(OutputStream outputStream, UueSaveOptions saveOptions)

public final void save(OutputStream outputStream, UueSaveOptions saveOptions)

Saves archive to the stream provided.

Writes compressed data to http response stream.


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

Parameters:

ParameterTypeDescription
outputStreamjava.io.OutputStreamdestination stream
saveOptionsUueSaveOptionsoptions for the archive saving

save(String destinationFileName)

public final void save(String destinationFileName)

Saves the archive to destination file provided.

Writes encoded data to file.


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

Parameters:

ParameterTypeDescription
destinationFileNamejava.lang.Stringthe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten

save(String destinationFileName, UueSaveOptions saveOptions)

public final void save(String destinationFileName, UueSaveOptions saveOptions)

Saves the archive to the destination file provided.

Writes encoded data to file.


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

Parameters:

ParameterTypeDescription
destinationFileNamejava.lang.Stringthe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten
saveOptionsUueSaveOptionsoptions for the archive saving

setSource(File file)

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:

ParameterTypeDescription
filejava.io.Filethe reference to a file to be compressed

setSource(InputStream source)

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:

ParameterTypeDescription
sourcejava.io.InputStreamthe input stream for the archive

setSource(String path)

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:

ParameterTypeDescription
pathjava.lang.Stringpath to file to be encoded