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


Java Inflater.reset方法代码示例

本文整理汇总了Java中java.util.zip.Inflater.reset方法的典型用法代码示例。如果您正苦于以下问题:Java Inflater.reset方法的具体用法?Java Inflater.reset怎么用?Java Inflater.reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.zip.Inflater的用法示例。


在下文中一共展示了Inflater.reset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: uncompress

import java.util.zip.Inflater; //导入方法依赖的package包/类
public int uncompress(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset, int maxOutputLength) throws IOException
{
    Inflater inf = inflater.get();
    inf.reset();
    inf.setInput(input, inputOffset, inputLength);
    if (inf.needsInput())
        return 0;

    // We assume output is big enough
    try
    {
        return inf.inflate(output, outputOffset, maxOutputLength);
    }
    catch (DataFormatException e)
    {
        throw new IOException(e);
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:19,代码来源:DeflateCompressor.java

示例2: read

import java.util.zip.Inflater; //导入方法依赖的package包/类
public static Area read(Save save, int x, int z) {
	FileHandle file = file(save, x, z);

	if (!file.exists()) {
		// Log.warning("Area does not exist");
		return null;
	}

	Inflater inflater = inflaterThreadLocal.get();

	try {
		inflater.reset();
		InputStream inputStream = file.read(8192);
		InflaterInputStream inflaterInputStream = new InflaterInputStream(inputStream, inflater);
		BufferedInputStream bufferedInputStream = new BufferedInputStream(inflaterInputStream);
		DataInputStream dataInputStream = new DataInputStream(bufferedInputStream);
		Area area = new Area(x, z);
		area.read(dataInputStream);
		dataInputStream.close();
		return area;
	} catch (Exception e) {
		Log.error("Failed to read area " + x + "," + z, e);
		return null;
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:26,代码来源:SaveAreaIO.java

示例3: read

import java.util.zip.Inflater; //导入方法依赖的package包/类
public static Area read(Save save, int x, int z) {
  FileHandle file = file(save, x, z);

  if (!file.exists()) {
    //Log.warning("Area does not exist");
    return null;
  }

  Inflater inflater = inflaterThreadLocal.get();

  try {
    inflater.reset();
    InputStream inputStream = file.read(8192);
    InflaterInputStream inflaterInputStream = new InflaterInputStream(inputStream, inflater);
    BufferedInputStream bufferedInputStream = new BufferedInputStream(inflaterInputStream);
    DataInputStream dataInputStream = new DataInputStream(bufferedInputStream);
    Area area = new Area(x, z);
    area.read(dataInputStream);
    dataInputStream.close();
    return area;
  } catch (Exception e) {
    Log.error("Failed to read area " + x + "," + z, e);
    return null;
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:26,代码来源:SaveAreaIO.java

示例4: divineDeflateParameters

import java.util.zip.Inflater; //导入方法依赖的package包/类
/**
 * Determines the original {@link JreDeflateParameters} that were used to compress a given piece
 * of deflated delivery.
 *
 * @param compressedDataInputStreamFactory a {@link MultiViewInputStreamFactory} that can provide
 *     multiple independent {@link InputStream} instances for the compressed delivery.
 * @return the parameters that can be used to replicate the compressed delivery in the {@link
 *     DefaultDeflateCompatibilityWindow}, if any; otherwise <code>null</code>. Note that <code>
 *     null</code> is also returned in the case of <em>corrupt</em> zip delivery since, by definition,
 *     it cannot be replicated via any combination of normal deflate parameters.
 * @throws IOException if there is a problem reading the delivery, i.e. if the file contents are
 *     changed while reading
 */
public JreDeflateParameters divineDeflateParameters(
    MultiViewInputStreamFactory compressedDataInputStreamFactory) throws IOException {
  byte[] copyBuffer = new byte[32 * 1024];
  // Iterate over all relevant combinations of nowrap, strategy and level.
  for (boolean nowrap : new boolean[] {true, false}) {
    Inflater inflater = new Inflater(nowrap);
    Deflater deflater = new Deflater(0, nowrap);

    strategy_loop:
    for (int strategy : new int[] {0, 1, 2}) {
      deflater.setStrategy(strategy);
      for (int level : LEVELS_BY_STRATEGY.get(strategy)) {
        deflater.setLevel(level);
        inflater.reset();
        deflater.reset();
        try {
          if (matches(inflater, deflater, compressedDataInputStreamFactory, copyBuffer)) {
            end(inflater, deflater);
            return JreDeflateParameters.of(level, strategy, nowrap);
          }
        } catch (ZipException e) {
          // Parse error in input. The only possibilities are corruption or the wrong nowrap.
          // Skip all remaining levels and strategies.
          break strategy_loop;
        }
      }
    }
    end(inflater, deflater);
  }
  return null;
}
 
开发者ID:lizhangqu,项目名称:CorePatch,代码行数:45,代码来源:DefaultDeflateCompressionDiviner.java

示例5: inflate

import java.util.zip.Inflater; //导入方法依赖的package包/类
private int inflate(byte[] src, byte[] dest) {
    Inflater inflater = (inflaterRef == null ? null : inflaterRef.get());

    // construct the inflater object or reuse an existing one
    if (inflater == null)
        inflaterRef = new SoftReference<Inflater>(inflater = new Inflater(true));

    inflater.reset();
    inflater.setInput(src);
    try {
        return inflater.inflate(dest);
    } catch (DataFormatException ex) {
        return -1;
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:16,代码来源:ZipFileIndex.java

示例6: releaseInflater

import java.util.zip.Inflater; //导入方法依赖的package包/类
private void releaseInflater(Inflater inf) {
    synchronized (inflaters) {
        if (inflaters.size() < MAX_FLATER) {
            inf.reset();
            inflaters.add(inf);
        } else {
            inf.end();
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:ZipFileSystem.java


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