Java Code Examples for org.apache.commons.compress.compressors.CompressorStreamFactory#createCompressorInputStream()
The following examples show how to use
org.apache.commons.compress.compressors.CompressorStreamFactory#createCompressorInputStream() .
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: NpmPackageParser.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
/** * Parses the package.json in the supplied tar.gz if present and extractable. In all other situations, an empty map * will be returned indicating the absence of (or inability to extract) a valid package.json file and its contents. */ public Map<String, Object> parsePackageJson(final Supplier<InputStream> supplier) { try (InputStream is = new BufferedInputStream(supplier.get())) { final CompressorStreamFactory compressorStreamFactory = new CompressorStreamFactory(); try (InputStream cis = compressorStreamFactory.createCompressorInputStream(GZIP, is)) { final ArchiveStreamFactory archiveFactory = new ArchiveStreamFactory(); try (ArchiveInputStream ais = archiveFactory.createArchiveInputStream(TAR, cis)) { return parsePackageJsonInternal(ais); } } } catch (Exception e) { log.debug("Error occurred while processing package.json, returning empty map to continue", e); return emptyMap(); } }
Example 2
Source File: FileLineFetcher.java From hugegraph-loader with Apache License 2.0 | 5 votes |
private static Reader createCompressReader(InputStream stream, FileSource source) throws Exception { Compression compression = source.compression(); String charset = source.charset(); switch (compression) { case NONE: return new InputStreamReader(stream, charset); case GZIP: case BZ2: case XZ: case LZMA: case SNAPPY_RAW: case SNAPPY_FRAMED: case Z: case DEFLATE: case LZ4_BLOCK: case LZ4_FRAMED: CompressorStreamFactory factory = new CompressorStreamFactory(); CompressorInputStream cis = factory.createCompressorInputStream( compression.string(), stream); return new InputStreamReader(cis, charset); default: throw new LoadException("Unsupported compression format '%s'", compression); } }
Example 3
Source File: PackagesGroupHandler.java From nexus-repository-r with Eclipse Public License 1.0 | 5 votes |
protected List<Map<String, String>> parseResponse(@Nonnull final Response response) { Payload payload = checkNotNull(response.getPayload()); try (InputStream in = payload.openInputStream()) { final CompressorStreamFactory compressorStreamFactory = new CompressorStreamFactory(); try (InputStream cin = compressorStreamFactory.createCompressorInputStream(GZIP, in)) { return RPackagesUtils.parseMetadata(cin); } } catch (IOException | CompressorException e) { throw new RException(null, e); } }
Example 4
Source File: RDescriptionUtils.java From nexus-repository-r with Eclipse Public License 1.0 | 5 votes |
private static Map<String, String> extractMetadataFromTgz(final InputStream is) { checkNotNull(is); try { final CompressorStreamFactory compressorStreamFactory = new CompressorStreamFactory(); try (InputStream cis = compressorStreamFactory.createCompressorInputStream(GZIP, is)) { return extractMetadataFromArchive(TAR, cis); } } catch (CompressorException | IOException e) { throw new RException(null, e); } }
Example 5
Source File: InputFile.java From kafka-connect-spooldir with Apache License 2.0 | 5 votes |
public InputStream openStream(boolean buffered) throws IOException { if (null != this.inputStream) { throw new IOException( String.format("File %s is already open", this.inputFile) ); } final String extension = Files.getFileExtension(inputFile.getName()); log.trace("openStream() - fileName = '{}' extension = '{}'", inputFile, extension); this.inputStream = new FileInputStream(this.inputFile); if (buffered) { log.trace( "openStream() - Wrapping '{}' in a BufferedInputStream with bufferSize = {}", this.inputFile, this.bufferSize ); this.inputStream = new BufferedInputStream(this.inputStream, this.bufferSize); } if (SUPPORTED_COMPRESSION_TYPES.containsKey(extension)) { final String compressor = SUPPORTED_COMPRESSION_TYPES.get(extension); log.info("Decompressing {} as {}", inputFile, compressor); final CompressorStreamFactory compressorStreamFactory = new CompressorStreamFactory(); try { this.inputStream = compressorStreamFactory.createCompressorInputStream( compressor, this.inputStream ); } catch (CompressorException e) { throw new IOException("Exception thrown while creating compressor stream " + compressor, e); } } log.info("Creating processing flag {}", this.processingFlag); Files.touch(this.processingFlag); return inputStream; }