Example usage for org.apache.commons.compress.utils SeekableInMemoryByteChannel SeekableInMemoryByteChannel

List of usage examples for org.apache.commons.compress.utils SeekableInMemoryByteChannel SeekableInMemoryByteChannel

Introduction

In this page you can find the example usage for org.apache.commons.compress.utils SeekableInMemoryByteChannel SeekableInMemoryByteChannel.

Prototype

public SeekableInMemoryByteChannel(int size) 

Source Link

Document

Constructor taking a size of storage to be allocated.

Usage

From source file:com.swemel.sevenzip.Extract.java

public static void main(String[] args) throws IOException {
    String fileName = "D:\\incubator\\commpressors\\test_100K_2_b.7z";
    //    SevenZFile sevenZFile = new SevenZFile(new File("D:\\incubator\\commpressors\\test_100K_2_b.7z"));
    byte[] inputData = IOUtils.toByteArray(new FileInputStream(fileName)); // 7z archive contents

    SeekableInMemoryByteChannel inMemoryByteChannel = new SeekableInMemoryByteChannel(inputData);
    SevenZFile sevenZFile = new SevenZFile(inMemoryByteChannel);

    SevenZArchiveEntry entry;//from  w  w  w. j  av a2  s. c o  m
    Iterable<SevenZArchiveEntry> entrys = sevenZFile.getEntries();
    for (SevenZArchiveEntry entry1 : entrys) {
        String name = entry1.getName();
        System.out.println("name = " + name + "\t" + entry1.toString());
    }
    ArrayList<InputStream> strams = sevenZFile.getStrams();
    String str = IOUtils.toString(strams.get(10));
    System.out.println("str = " + str);
    //   entry = sevenZFile.getNextEntry();
    //   sevenZFile.read();  // read current entry's data
}

From source file:org.apache.james.mailbox.backup.ZipperTest.java

private SeekableInMemoryByteChannel toSeekableByteChannel(ByteArrayOutputStream output) {
    return new SeekableInMemoryByteChannel(output.toByteArray());
}