當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。