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.
getFormat()Gets the archive format.
getLength()Gets length.
getName()Name of the 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 the 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) {#UueArchive-java.io.InputStream-}

public UueArchive(InputStream sourceStream)



Initializes a new instance of the [UueArchive](../../com.aspose.zip/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()](../../com.aspose.zip/uuearchive\#open--) method for decompressing.

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| sourceStream | java.io.InputStream | the source of the archive |

### UueArchive(String path) {#UueArchive-java.lang.String-}
```
public UueArchive(String path)
```


Initializes a new instance of the [UueArchive](../../com.aspose.zip/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()](../../com.aspose.zip/uuearchive\#open--) method for decompressing.

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| path | java.lang.String | the path to the archive file |

### close() {#close--}

public void close()





### extract(OutputStream destination) {#extract-java.io.OutputStream-}

public final void extract(OutputStream destination)



Extracts the archive to the stream provided.

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



**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| destination | java.io.OutputStream | destination stream |

### extract(String path) {#extract-java.lang.String-}
```
public final File extract(String path)
```


Extracts the archive to the file by path.

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| path | java.lang.String | the path to destination file. If the file already exists, it will be overwritten |

**Returns:**
java.io.File - info of the extracted file
### extractToDirectory(String destinationDirectory) {#extractToDirectory-java.lang.String-}
```
public final void extractToDirectory(String destinationDirectory)
```


Extracts content of the archive to the directory provided.

**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| destinationDirectory | java.lang.String | the path to the directory to place the extracted files in.

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

### getFileEntries() {#getFileEntries--}
```
public final Iterable<IArchiveFileEntry> getFileEntries()
```


Gets entries of [IArchiveFileEntry](../../com.aspose.zip/iarchivefileentry) type constituting the uue archive.

**Returns:**
java.lang.Iterable&lt;com.aspose.zip.IArchiveFileEntry&gt; - entries of [IArchiveFileEntry](../../com.aspose.zip/iarchivefileentry) type constituting the uue archive
### getFormat() {#getFormat--}
```
public final ArchiveFormat getFormat()
```


Gets the archive format.

**Returns:**
[ArchiveFormat](../../com.aspose.zip/archiveformat) - the archive format
### getLength() {#getLength--}
```
public final Long getLength()
```


Gets length.

**Returns:**
java.lang.Long - length
### getName() {#getName--}
```
public final String getName()
```


Name of the original file.

**Returns:**
java.lang.String - the name of the original file
### open() {#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:**
java.io.InputStream - the stream that represents the contents of the archive
### save(OutputStream outputStream) {#save-java.io.OutputStream-}

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:**
| Parameter | Type | Description |
| --- | --- | --- |
| outputStream | java.io.OutputStream | destination stream |

### save(OutputStream outputStream, UueSaveOptions saveOptions) {#save-java.io.OutputStream-com.aspose.zip.UueSaveOptions-}
```
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:**
| Parameter | Type | Description |
| --- | --- | --- |
| outputStream | java.io.OutputStream | destination stream |
| saveOptions | [UueSaveOptions](../../com.aspose.zip/uuesaveoptions) | options for the archive saving |

### save(String destinationFileName) {#save-java.lang.String-}

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:**
| Parameter | Type | Description |
| --- | --- | --- |
| destinationFileName | java.lang.String | the 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) {#save-java.lang.String-com.aspose.zip.UueSaveOptions-}
```
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:**
| Parameter | Type | Description |
| --- | --- | --- |
| destinationFileName | java.lang.String | the path of the archive to be created. If the specified file name points to an existing file, it will be overwritten |
| saveOptions | [UueSaveOptions](../../com.aspose.zip/uuesaveoptions) | options for the archive saving |

### setSource(File file) {#setSource-java.io.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:**
| Parameter | Type | Description |
| --- | --- | --- |
| file | java.io.File | the reference to a file to be compressed |

### setSource(InputStream source) {#setSource-java.io.InputStream-}
```
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:**
| Parameter | Type | Description |
| --- | --- | --- |
| source | java.io.InputStream | the input stream for the archive |

### setSource(String path) {#setSource-java.lang.String-}

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:**
| Parameter | Type | Description |
| --- | --- | --- |
| path | java.lang.String | path to file to be encoded |