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

The following examples show how to use org.apache.commons.compress.utils.SeekableInMemoryByteChannel. 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 File: YosegiArrowWriter.java    From yosegi with Apache License 2.0 6 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();
    arrowReader.loadRecordBatch(block);
    append( root );
  }
}
 
Example #2
Source File: Spec256Arch.java    From zxpoly with GNU General Public License v3.0 5 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()) {
        continue;
      }
      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 = matcher.group(1);
        final byte[] snaFileBody = readData(zipFile, entry);
        return new FoundSna(
            parsedSnaName,
            snaFileBody,
            new SNAParser().read(new JBBPBitInputStream(new ByteArrayInputStream(snaFileBody)))
        );
      }
    }
  }
  return null;
}
 
Example #3
Source File: ZipAssert.java    From james-project with 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 File: ZipAssert.java    From james-project with 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)));
}