Example #1
0
 public void compressFile() throws Exception {
   try {
     if (debug) System.out.println("Compress without tar at line 51.");
     int len;
     String outFilePath, inFilePath;
     outFilePath = outFile.getAbsolutePath();
     inFilePath = inFile.getAbsolutePath();
     outStream = new CBZip2OutputStream(new FileOutputStream(outFilePath));
     inStream = new BufferedInputStream(new FileInputStream(inFilePath));
     byte[] buffer = new byte[BUFFERSIZE];
     while ((len = inStream.read(buffer)) > 0 && !compressDialog.isCanceled())
       outStream.write(buffer, 0, len);
   } catch (Exception ex) {
     outFile.delete();
     compressDialog.cancelDialog();
     throw new Exception(compressError + className + newline + ex.getMessage());
   } finally {
     try {
       if (inStream != null) inStream.close();
       if (outStream != null) {
         outStream.flush();
         outStream.close();
       }
       if (compressDialog.isCanceled()) outFile.delete();
     } catch (Exception ex) {
       outFile.delete();
       compressDialog.cancelDialog();
       throw new Exception(StreamCloseError + className + newline + ex.getMessage());
     }
   }
 }
Example #2
0
 public void tarAndCompressFile() throws Exception {
   try {
     if (debug) System.out.println("Compress with tar at line 98.");
     String outFilePath = outFile.getAbsolutePath();
     outStream = new CBZip2OutputStream(new FileOutputStream(outFilePath));
     new CreateArchive(outStream, inFile, outFile, compressDialog);
   } catch (Exception ex) {
     outFile.delete();
     compressDialog.cancelDialog();
     throw new Exception(compressError + className + newline + ex.getMessage());
   } finally {
     try {
       if (outStream != null) outStream.close();
     } catch (Exception ex) {
       compressDialog.cancelDialog();
       throw new Exception(StreamCloseError + className + newline + ex.getMessage());
     }
   }
 }