Java Code Examples for java.util.zip.CheckedOutputStream#close()

The following examples show how to use java.util.zip.CheckedOutputStream#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZipMeUp.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 2
Source File: ZipMeUp.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 3
Source File: ZipMeUp.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 4
Source File: ZipMeUp.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 5
Source File: ZipMeUp.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 6
Source File: ZipMeUp.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 7
Source File: ZipMeUp.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 8
Source File: ZipMeUp.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 9
Source File: ZipMeUp.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 10
Source File: ZipMeUp.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 11
Source File: ZipMeUp.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 12
Source File: ZipMeUp.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 13
Source File: ZipMeUp.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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();
}
 
Example 14
Source File: ApplicationBundler.java    From twill with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example 15
Source File: ArscFileGenerator.java    From Baffle with MIT License 5 votes vote down vote up
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;
}
 
Example 16
Source File: ArscData.java    From Baffle with MIT License 5 votes vote down vote up
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;
}