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


Java CheckedOutputStream.close方法代码示例

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


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

示例1: serialize

import java.util.zip.CheckedOutputStream; //导入方法依赖的package包/类
/**
 * serialize the datatree and session into the file snapshot
 * @param dt the datatree to be serialized
 * @param sessions the sessions to be serialized
 * @param snapShot the file to store snapshot into
 */
public synchronized void serialize(DataTree dt, Map<Long, Integer> sessions, File snapShot)
        throws IOException {
    if (!close) {
        OutputStream sessOS = new BufferedOutputStream(new FileOutputStream(snapShot));
        CheckedOutputStream crcOut = new CheckedOutputStream(sessOS, new Adler32());
        //CheckedOutputStream cout = new CheckedOutputStream()
        OutputArchive oa = BinaryOutputArchive.getArchive(crcOut);
        FileHeader header = new FileHeader(SNAP_MAGIC, VERSION, dbId);
        serialize(dt,sessions,oa, header);
        long val = crcOut.getChecksum().getValue();
        oa.writeLong(val, "val");
        oa.writeString("/", "path");
        sessOS.flush();
        crcOut.close();
        sessOS.close();
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:24,代码来源:FileSnap.java

示例2: getManifestAsBytes

import java.util.zip.CheckedOutputStream; //导入方法依赖的package包/类
static byte[] getManifestAsBytes(int nchars) throws IOException {
    crc.reset();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    CheckedOutputStream cos = new CheckedOutputStream(baos, crc);
    PrintStream ps = new PrintStream(cos);
    ps.println("Manifest-Version: 1.0");
    ps.print("Main-Class: ");
    for (int i = 0 ; i < nchars - SOME_KLASS.length() ; i++) {
        ps.print(i%10);
    }
    ps.println(SOME_KLASS);
    cos.flush();
    cos.close();
    ps.close();
    return baos.toByteArray();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:ZipMeUp.java

示例3: serialize

import java.util.zip.CheckedOutputStream; //导入方法依赖的package包/类
/**
 * serialize the datatree and session into the file snapshot
 * @param dt the datatree to be serialized
 * @param sessions the sessions to be serialized
 * @param snapShot the file to store snapshot into
 */
@Override
public synchronized void serialize(DataTree dt, Map<Long, Long> sessions, File snapShot)
        throws IOException {
    if (!close) {
        OutputStream sessOS = new BufferedOutputStream(new FileOutputStream(snapShot));
        CheckedOutputStream crcOut = new CheckedOutputStream(sessOS, new Adler32());
        //CheckedOutputStream cout = new CheckedOutputStream()
        OutputArchive oa = BinaryOutputArchive.getArchive(crcOut);
        FileHeader header = new FileHeader(SNAP_MAGIC, VERSION, dbId);
        serialize(dt,sessions,oa, header);
        long val = crcOut.getChecksum().getValue();
        oa.writeLong(val, "val");
        oa.writeString("/", "path");
        sessOS.flush();
        crcOut.close();
        sessOS.close();
    }
}
 
开发者ID:anhnv-3991,项目名称:VoltDB,代码行数:25,代码来源:FileSnap.java

示例4: saveEntry

import java.util.zip.CheckedOutputStream; //导入方法依赖的package包/类
/**
 * Saves a class entry to the jar output.
 */
private void saveEntry(String entry, URL url, Set<String> entries, JarOutputStream jarOut, boolean compress) {
  if (!entries.add(entry)) {
    return;
  }
  LOG.trace("adding bundle entry " + entry);
  try {
    JarEntry jarEntry = new JarEntry(entry);

    try (InputStream is = url.openStream()) {
      if (compress) {
        jarOut.putNextEntry(jarEntry);
        ByteStreams.copy(is, jarOut);
      } else {
        crc32.reset();
        TransferByteOutputStream os = new TransferByteOutputStream();
        CheckedOutputStream checkedOut = new CheckedOutputStream(os, crc32);
        ByteStreams.copy(is, checkedOut);
        checkedOut.close();

        long size = os.size();
        jarEntry.setMethod(JarEntry.STORED);
        jarEntry.setSize(size);
        jarEntry.setCrc(checkedOut.getChecksum().getValue());
        jarOut.putNextEntry(jarEntry);
        os.transfer(jarOut);
      }
    }
    jarOut.closeEntry();
  } catch (Exception e) {
    throw Throwables.propagate(e);
  }
}
 
开发者ID:apache,项目名称:twill,代码行数:36,代码来源:ApplicationBundler.java

示例5: createObfuscateFile

import java.util.zip.CheckedOutputStream; //导入方法依赖的package包/类
public  CRC32 createObfuscateFile( ArscData data, StringBlock tableBlock,
        StringBlock keyBlock, File file ) throws IOException {
    FileOutputStream fileOutputStream = new FileOutputStream(file);
    CRC32 cksum = new CRC32();
    CheckedOutputStream checkedOutputStream = new CheckedOutputStream(fileOutputStream, cksum);
    LEDataOutputStream out = new LEDataOutputStream(checkedOutputStream);
    
    int tableStrChange = data.getmTableStrings().getSize() - tableBlock.getSize();
    int keyStrChange = data.getmSpecNames().getSize() - keyBlock.getSize();
    data.getmHeader().chunkSize -=(tableStrChange + keyStrChange);
    data.getmHeader().write(out);
    out.writeInt(1);
    tableBlock.write(out);
    data.getmPkgHeader().header.chunkSize -=keyStrChange;
    data.getmPkgHeader().write(out);
    data.getTypeNames().write(out);
    keyBlock.write(out);
    
    byte[] buff = new byte[1024];
    FileInputStream in = new FileInputStream(data.getFile());
    in.skip(data.getmResIndex());
    int len ;
    while(((len = in.read(buff)) != -1)){
        out.write(buff , 0 , len);
    }
    
    in.close();
    out.close();
    checkedOutputStream.close();
    fileOutputStream.close();
    return cksum;
}
 
开发者ID:joker535,项目名称:Baffle,代码行数:33,代码来源:ArscFileGenerator.java

示例6: createObfuscateFile

import java.util.zip.CheckedOutputStream; //导入方法依赖的package包/类
public CRC32 createObfuscateFile(StringBlock tableBlock,
        StringBlock keyBlock, File file ) throws IOException {
    FileOutputStream fileOutputStream = new FileOutputStream(file);
    CRC32 cksum = new CRC32();
    CheckedOutputStream checkedOutputStream = new CheckedOutputStream(fileOutputStream, cksum);
    LEDataOutputStream out = new LEDataOutputStream(checkedOutputStream);
    
    int tableStrChange = getmTableStrings().getSize() - tableBlock.getSize();
    int keyStrChange = getmSpecNames().getSize() - keyBlock.getSize();
    getmHeader().chunkSize -=(tableStrChange + keyStrChange);
    getmHeader().write(out);
    out.writeInt(1);
    tableBlock.write(out);
    getmPkgHeader().header.chunkSize -=keyStrChange;
    getmPkgHeader().write(out);
    getTypeNames().write(out);
    keyBlock.write(out);
    
    byte[] buff = new byte[1024];
    FileInputStream in = new FileInputStream(getFile());
    in.skip(getmResIndex());
    int len ;
    while(((len = in.read(buff)) != -1)){
        out.write(buff , 0 , len);
    }
    
    in.close();
    out.close();
    checkedOutputStream.close();
    fileOutputStream.close();
    return cksum;
}
 
开发者ID:joker535,项目名称:Baffle,代码行数:33,代码来源:ArscData.java

示例7: saveEntry

import java.util.zip.CheckedOutputStream; //导入方法依赖的package包/类
/**
 * Saves a class entry to the jar output.
 */
private void saveEntry(String entry, URL url, Set<String> entries, JarOutputStream jarOut, boolean compress) {
  if (!entries.add(entry)) {
    return;
  }
  LOG.trace("adding bundle entry " + entry);
  try {
    JarEntry jarEntry = new JarEntry(entry);
    InputStream is = url.openStream();

    try {
      if (compress) {
        jarOut.putNextEntry(jarEntry);
        ByteStreams.copy(is, jarOut);
      } else {
        crc32.reset();
        TransferByteOutputStream os = new TransferByteOutputStream();
        CheckedOutputStream checkedOut = new CheckedOutputStream(os, crc32);
        ByteStreams.copy(is, checkedOut);
        checkedOut.close();

        long size = os.size();
        jarEntry.setMethod(JarEntry.STORED);
        jarEntry.setSize(size);
        jarEntry.setCrc(checkedOut.getChecksum().getValue());
        jarOut.putNextEntry(jarEntry);
        os.transfer(jarOut);
      }
    } finally {
      is.close();
    }
    jarOut.closeEntry();
  } catch (Exception e) {
    throw Throwables.propagate(e);
  }
}
 
开发者ID:chtyim,项目名称:incubator-twill,代码行数:39,代码来源:ApplicationBundler.java


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