Example usage for org.apache.commons.compress.tar TarOutputStream copyEntryContents

List of usage examples for org.apache.commons.compress.tar TarOutputStream copyEntryContents

Introduction

In this page you can find the example usage for org.apache.commons.compress.tar TarOutputStream copyEntryContents.

Prototype

public void copyEntryContents(final InputStream input) throws IOException 

Source Link

Document

Copies the contents of the specified stream into current tar archive entry.

Usage

From source file:ja.lingo.engine.Exporter.java

private void putListFile(File listTempFile, TarOutputStream tos) throws IOException {
    // list: append as a TAR entry
    TarEntry entry = new TarEntry("list.html");
    entry.setSize(listTempFile.length());
    tos.putNextEntry(entry);/*from  w  w w  .j a  va  2s.c o m*/

    FileInputStream fis = null;
    try {
        fis = new FileInputStream(listTempFile);
        tos.copyEntryContents(fis);
    } finally {
        if (fis != null) {
            try {
                fis.close();
            } catch (IOException e) {
                LOG.error("Exception caught when tried to close list HTML FileInputStream", e);
            }
        }
    }
    tos.closeEntry();
}

From source file:org.dcm4chex.archive.hsm.FileCopyService.java

private void writeFile(TarOutputStream tar, FileInfo fileInfo, String tarEntryName)
        throws IOException, FileNotFoundException {
    File file = FileUtils.toFile(fileInfo.basedir, fileInfo.fileID);
    if (file.length() != fileInfo.size) {
        log.error("Filesize doesn't match for file entry:" + fileInfo + "!(" + file.length() + " vs. "
                + fileInfo.size + ") skipped!");
        throw new IOException("Filesize doesn't match! file:" + file);
    }//from w w w.jav a 2  s  .  c o m
    TarEntry entry = new TarEntry(tarEntryName);
    entry.setSize(fileInfo.size);
    tar.putNextEntry(entry);
    FileInputStream fis = new FileInputStream(file);
    try {
        tar.copyEntryContents(fis);
    } finally {
        fis.close();
    }
    tar.closeEntry();
}

From source file:org.dcm4chex.archive.hsm.FileMoveService.java

private File writeFile(TarOutputStream tar, FileDTO dto, String tarEntryName)
        throws IOException, FileNotFoundException {
    File file = FileUtils.toFile(dto.getDirectoryPath(), dto.getFilePath());
    TarEntry entry = new TarEntry(tarEntryName);
    entry.setSize(dto.getFileSize());/*w  w w.  j a  v a 2  s.  co m*/
    tar.putNextEntry(entry);
    FileInputStream fis = new FileInputStream(file);
    try {
        tar.copyEntryContents(fis);
    } finally {
        fis.close();
    }
    tar.closeEntry();
    return file;
}