本文整理汇总了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();
}
}
示例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();
}
示例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();
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}