Java Code Examples for org.apache.commons.compress.utils.SeekableInMemoryByteChannel

The following examples show how to use org.apache.commons.compress.utils.SeekableInMemoryByteChannel. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: zxpoly   Source File:    License: GNU General Public License v3.0 6 votes vote down vote up
private static FoundSna findSna(final byte[] zipArchive) throws IOException {
  try (ZipFile zipFile = new ZipFile(new SeekableInMemoryByteChannel(zipArchive))) {
    final Enumeration<ZipArchiveEntry> iterator = zipFile.getEntries();
    while (iterator.hasMoreElements()) {
      final ZipArchiveEntry entry = iterator.nextElement();
      if (entry.isDirectory()) {
      final String name = entry.getName().replace('\\', '/').toLowerCase(Locale.ENGLISH);
      if (name.endsWith(".sna")) {
        final Matcher matcher = SNA_NAME_PATTERN.matcher(name);
        if (!matcher.find()) {
          throw new IOException("Unexpected SNA name: " + name);
        String parsedSnaName =;
        final byte[] snaFileBody = readData(zipFile, entry);
        return new FoundSna(
            new SNAParser().read(new JBBPBitInputStream(new ByteArrayInputStream(snaFileBody)))
  return null;
Example 2
Source Project: yosegi   Source File:    License: Apache License 2.0 5 votes vote down vote up
 * Append from arrow byte array.
public void append( final byte[] buffer ) throws IOException {
  ArrowFileReader arrowReader = new ArrowFileReader(
      new SeekableInMemoryByteChannel( buffer ) , new RootAllocator( Integer.MAX_VALUE ) );
  List<ArrowBlock> blockList = arrowReader.getRecordBlocks();
  for ( ArrowBlock block : blockList ) {
    VectorSchemaRoot root = arrowReader.getVectorSchemaRoot();
    append( root );
Example 3
Source Project: james-project   Source File:    License: Apache License 2.0 4 votes vote down vote up
public static ZipAssert assertThatZip(ByteArrayOutputStream outputStream) throws IOException {
    return assertThatZip(new ZipFile(new SeekableInMemoryByteChannel(outputStream.toByteArray())));
Example 4
Source Project: james-project   Source File:    License: Apache License 2.0 4 votes vote down vote up
private static ZipFile zipFileFromInputStream(InputStream inputStream) throws IOException {
    return new ZipFile(new SeekableInMemoryByteChannel(IOUtils.toByteArray(inputStream)));