当前位置: 首页>>代码示例>>Java>>正文


Java BZip2CompressorInputStream类代码示例

本文整理汇总了Java中org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream的典型用法代码示例。如果您正苦于以下问题:Java BZip2CompressorInputStream类的具体用法?Java BZip2CompressorInputStream怎么用?Java BZip2CompressorInputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BZip2CompressorInputStream类属于org.apache.commons.compress.compressors.bzip2包,在下文中一共展示了BZip2CompressorInputStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupSegmentsAndOutput

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
private void setupSegmentsAndOutput(PatchExecutor executor)
    throws CompressorException, IOException {
  controlBlockLen = readOffset();
  diffBlockLen = readOffset();
  int newFileSize = readOffset();

  extraBlockLen =
      patchInput.array().length - (BSDIFF_HEADER_LENGTH + controlBlockLen + diffBlockLen);

  executor.createOutput(newFileSize);
  controlStream = new BZip2CompressorInputStream(
      new ByteArrayInputStream(patchInput.array(), BSDIFF_HEADER_LENGTH, controlBlockLen));
  diffStream = new BZip2CompressorInputStream(
      new ByteArrayInputStream(patchInput.array(), BSDIFF_HEADER_LENGTH + controlBlockLen,
          diffBlockLen));
  extraStream = new BZip2CompressorInputStream(
      new ByteArrayInputStream(patchInput.array(),
          BSDIFF_HEADER_LENGTH + controlBlockLen + diffBlockLen,
          extraBlockLen));
}
 
开发者ID:inferjay,项目名称:r8,代码行数:21,代码来源:BSPatch.java

示例2: uncompress

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
@Override
public byte[] uncompress(byte[] data) throws IOException {
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	ByteArrayInputStream in = new ByteArrayInputStream(data);

	try {
		@SuppressWarnings("resource")
		BZip2CompressorInputStream ungzip = new BZip2CompressorInputStream(in);
		byte[] buffer = new byte[2048];
		int n;
		while ((n = ungzip.read(buffer)) >= 0) {
			out.write(buffer, 0, n);
		}
	} catch (IOException e) {
		e.printStackTrace();
	}

	return out.toByteArray();
}
 
开发者ID:yu120,项目名称:compress,代码行数:20,代码来源:Bzip2Compress.java

示例3: readRecordsDirectly

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
public String[] readRecordsDirectly(URL testFileUrl, boolean bzip)
    throws IOException {
  int MAX_DATA_SIZE = 1024 * 1024;
  byte[] data = new byte[MAX_DATA_SIZE];
  FileInputStream fis = new FileInputStream(testFileUrl.getFile());
  int count;
  if (bzip) {
    BZip2CompressorInputStream bzIn = new BZip2CompressorInputStream(fis);
    count = bzIn.read(data);
    bzIn.close();
  } else {
    count = fis.read(data);
  }
  fis.close();
  assertTrue("Test file data too big for buffer", count < data.length);
  return new String(data, 0, count, "UTF-8").split("\n");
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestLineRecordReader.java

示例4: startRevisionProcessing

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
@Override
public void startRevisionProcessing() {
	logger.debug("Starting...");
	try {
		BufferedReader csvReader;

		csvReader = new BufferedReader(
		new InputStreamReader(
		new BZip2CompressorInputStream(
		new BufferedInputStream(
		new FileInputStream(geolocationFeatureFile))), "UTF-8"));

		csvParser = new CSVParser(csvReader,
				CSVFormat.RFC4180.withHeader());
		iterator = csvParser.iterator();
	
		processor.startRevisionProcessing();
	
	} catch (IOException e) {
		logger.error("", e);
	}
}
 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:23,代码来源:GeolocationFeatureProcessor.java

示例5: startRevisionProcessing

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
@Override
public void startRevisionProcessing() {
	logger.info("Starting...");
	
	InputStream compressedLabelsInputStream;
	
	try {
		compressedLabelsInputStream = new FileInputStream(labelFile);

		InputStream uncompressedLabelsInputStream =
				new BZip2CompressorInputStream(
				new BufferedInputStream(compressedLabelsInputStream));
		
		labelReader = new CorpusLabelReader(uncompressedLabelsInputStream);
	
	} catch (IOException e) {
		logger.error("", e);
	}		
	
	processor.startRevisionProcessing();
	
	labelReader.startReading();
}
 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:24,代码来源:CorpusLabelProcessor.java

示例6: getUncompressedStream

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
private static InputStream getUncompressedStream(
		final InputStream inputStream) throws IOException {
	// the decompression is a major bottleneck, make sure that it does not
	// have to wait for the buffer to empty
	final PipedOutputStream pipedOutputStream = new PipedOutputStream();
	final PipedInputStream pipedInputStream = new PipedInputStream(pipedOutputStream, BUFFER_SIZE);
	
	new Thread("Dump File Decompressor") {
		@Override
		public void run() {
			try {
				InputStream compressorInputStream =
						new BZip2CompressorInputStream(inputStream);
				
				IOUtils.copy(compressorInputStream, pipedOutputStream);
				
				compressorInputStream.close();
				pipedOutputStream.close();
			} catch (IOException e) {
				logger.error("", e);
			}
		}
	}.start();
	
	return pipedInputStream;
}
 
开发者ID:heindorf,项目名称:cikm16-wdvd-feature-extraction,代码行数:27,代码来源:FeatureExtractor.java

示例7: decompress

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
public static byte[] decompress(byte[] bytes, int len) throws IOException
{
	byte[] data = new byte[len + BZIP_HEADER.length];

	// add header
	System.arraycopy(BZIP_HEADER, 0, data, 0, BZIP_HEADER.length);
	System.arraycopy(bytes, 0, data, BZIP_HEADER.length, len);

	ByteArrayOutputStream os = new ByteArrayOutputStream();

	try (InputStream is = new BZip2CompressorInputStream(new ByteArrayInputStream(data)))
	{
		IOUtils.copy(is, os);
	}

	return os.toByteArray();
}
 
开发者ID:runelite,项目名称:runelite,代码行数:18,代码来源:BZip2.java

示例8: Stagger

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
@Inject
public Stagger(@LanguageCode String lang, @Model(MODEL_ID) Resource path) throws LangforiaException {
	this(lang);

	Logger logger = LoggerFactory.getLogger(Stagger.class);

	logger.info("Loading stagger model " + path.name());
	try
	{
		ObjectInputStream modelReader = new ObjectInputStream(new BufferedInputStream(new BZip2CompressorInputStream(path.binaryRead()), 1024*1024));
		tagger = (Tagger)modelReader.readObject();
		modelReader.close();
	}
	catch(Exception ex)
	{
		throw new LangforiaException("Failed to load stagger model.", ex);
	}

	posTagSet = tagger.getTaggedData().getPosTagSet();
	neTagSet = tagger.getTaggedData().getNETagSet();
	neTagTypeSet = tagger.getTaggedData().getNETypeTagSet();
	logger.info("Stagger model loaded.");
}
 
开发者ID:marcusklang,项目名称:langforia,代码行数:24,代码来源:Stagger.java

示例9: decodeAsInputStream

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
/**
 * Decodes a byte array as an InputStream. The byte array may be compressed using some
 * codec. Reads from the returned stream will result in decompressed bytes.
 *
 * <p>This supports the same codecs as Avro's {@link CodecFactory}, namely those defined in
 * {@link DataFileConstants}.
 *
 * <ul>
 * <li>"snappy" : Google's Snappy compression
 * <li>"deflate" : deflate compression
 * <li>"bzip2" : Bzip2 compression
 * <li>"xz" : xz compression
 * <li>"null" (the string, not the value): Uncompressed data
 * </ul>
 */
private static InputStream decodeAsInputStream(byte[] data, String codec) throws IOException {
  ByteArrayInputStream byteStream = new ByteArrayInputStream(data);
  switch (codec) {
    case DataFileConstants.SNAPPY_CODEC:
      return new SnappyCompressorInputStream(byteStream, 1 << 16 /* Avro uses 64KB blocks */);
    case DataFileConstants.DEFLATE_CODEC:
      // nowrap == true: Do not expect ZLIB header or checksum, as Avro does not write them.
      Inflater inflater = new Inflater(true);
      return new InflaterInputStream(byteStream, inflater);
    case DataFileConstants.XZ_CODEC:
      return new XZCompressorInputStream(byteStream);
    case DataFileConstants.BZIP2_CODEC:
      return new BZip2CompressorInputStream(byteStream);
    case DataFileConstants.NULL_CODEC:
      return byteStream;
    default:
      throw new IllegalArgumentException("Unsupported codec: " + codec);
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:35,代码来源:AvroSource.java

示例10: getBufferedReader

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
public static BufferedReader getBufferedReader (File file) throws FileNotFoundException, IOException
{
	
	if (file.getName().matches("^.+\\.gz$")||file.getName().matches("^.+\\.gzip$"))
	{
		GZIPInputStream gzip = new GZIPInputStream(new FileInputStream(file));
		return new BufferedReader(new InputStreamReader(gzip));
	}
	else if(file.getName().matches("^.+\\.bz2$")||file.getName().matches("^.+\\.bzip2$"))
	{
		BZip2CompressorInputStream bzIn = new BZip2CompressorInputStream(new FileInputStream(file));
		return new BufferedReader(new InputStreamReader(bzIn));
	}
	else
	{
		return new BufferedReader(new FileReader(file));
	}
	
}
 
开发者ID:enasequence,项目名称:sequencetools,代码行数:20,代码来源:GCSEntryReader.java

示例11: downloadOpenH264

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
private static void downloadOpenH264(File target, String libraryName) throws UnsatisfiedLinkError
{
   try
   {
      URL url = getVersionURL(libraryName);
      System.out.println("Downloading " + url + " to " + target);
      InputStream remote = url.openStream();
      BZip2CompressorInputStream decompressor = new BZip2CompressorInputStream(remote);
      NativeLibraryLoader.writeStreamToFile(decompressor, target);
      remote.close();

   }
   catch (IOException e)
   {
      throw new UnsatisfiedLinkError("Cannot download OpenH264 binary " + libraryName + " to " + target + ". Are you connected to the internet?");
   }
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:18,代码来源:OpenH264Downloader.java

示例12: getDumpReader

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
/**
 * The dump parser can deal with gzip, bzip or uncompressed files. This file
 * select the right reader.
 */
public BufferedReader getDumpReader(String file)
		throws UnsupportedEncodingException, FileNotFoundException {
	// attempt to use gzip first
	BufferedReader br = null;
	try {
		br = new BufferedReader(new InputStreamReader(new GZIPInputStream(
				new FileInputStream(new File(file))), "UTF-8"), 16 * 1024);
	} catch (IOException e) {
		System.out.println(file
				+ " is not gzipped, trying bzip input stream..");
		try {
			FileInputStream fin = new FileInputStream(file);
			BufferedInputStream in = new BufferedInputStream(fin);
			BZip2CompressorInputStream bzIn = new BZip2CompressorInputStream(
					in);
			br = new BufferedReader(new InputStreamReader(bzIn));
		} catch (IOException f) {
			System.out.println(file
					+ " is not bzip commpressed, trying decompressed file");
			br = new BufferedReader(new InputStreamReader(
					new FileInputStream(new File(file)), "UTF8"), 16 * 1024);
		}
	}
	return br;
}
 
开发者ID:diffbot,项目名称:wikistatsextractor,代码行数:30,代码来源:DumpParser.java

示例13: openCompressedStream

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
/**
 * open a compressed InputStream
 * @param in the InputStream to decompress
 * @return the InputStream to read from
 * @throws IOException if an I/O error occurs
 */
private InputStream openCompressedStream(InputStream in) throws IOException {
  if(mCurrentTask.compression==null)
    return in;
  switch(mCurrentTask.compression) {
    default:
    case none:
      return in;
    case gzip:
      return new GzipCompressorInputStream(in);
    case bzip:
      return new BZip2CompressorInputStream(in);
    case xz:
      return new XZCompressorInputStream(in);
  }
}
 
开发者ID:Android-leak,项目名称:csploit,代码行数:22,代码来源:UpdateService.java

示例14: getBufferedReader

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
/**
 * 
 * @return a BufferedReader created from wikiDumpFilename
 * @throws UnsupportedEncodingException
 * 
 */
public static BufferedReader getBufferedReader(String wikiDumpFilename) throws UnsupportedEncodingException,
		FileNotFoundException, IOException {
	BufferedReader br = null;

	if (wikiDumpFilename.endsWith(".gz")) {

		br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(wikiDumpFilename)), "UTF-8"));

	} else if (wikiDumpFilename.endsWith(".bz2")) {
		FileInputStream fis = new FileInputStream(wikiDumpFilename);
		br = new BufferedReader(new InputStreamReader(new BZip2CompressorInputStream(fis), "UTF-8"));
	} else {
		br = new BufferedReader(new InputStreamReader(new FileInputStream(wikiDumpFilename), "UTF-8"));
	}

	return br;
}
 
开发者ID:naveenmadhire,项目名称:json-wikipedia-dbspotlight,代码行数:24,代码来源:WikiXMLParser.java

示例15: extractBzip2ByteArray

import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; //导入依赖的package包/类
private byte[] extractBzip2ByteArray(byte[] data) {
	byte[] b = null;
	try {
		ByteArrayInputStream bis = new ByteArrayInputStream(data);
		BZip2CompressorInputStream bzip2 = new BZip2CompressorInputStream(bis);
		byte[] buf = new byte[1024];
		int num = -1;
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		while ((num = bzip2.read(buf, 0, buf.length)) != -1) {
			baos.write(buf, 0, num);
		}
		b = baos.toByteArray();
		baos.flush();
		baos.close();
		bzip2.close();
		bis.close();
	} catch (Exception ex) {
		ex.printStackTrace();
	}
	return b;

}
 
开发者ID:GIScience,项目名称:osmgpxfilter,代码行数:23,代码来源:OsmGpxScraper.java


注:本文中的org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。