Search in sources :

Example 1 with LzmaOutputStream

use of lzma.streams.LzmaOutputStream in project SKMCLauncher by SKCraft.

the class UpdateBuilder method copyFileLzma.

@SuppressWarnings("unused")
private static void copyFileLzma(File sourceFile, File destFile) throws IOException {
    destFile.getParentFile().mkdirs();
    FileInputStream fis = null;
    BufferedInputStream bis = null;
    FileOutputStream fos = null;
    BufferedOutputStream bos = null;
    LzmaOutputStream compress = null;
    try {
        fis = new FileInputStream(sourceFile);
        bis = new BufferedInputStream(fis);
        fos = new FileOutputStream(destFile);
        bos = new BufferedOutputStream(fos);
        compress = new LzmaOutputStream(bos, new Encoder());
        byte[] buffer = new byte[1024 * 8];
        int length;
        while ((length = bis.read(buffer)) > 0) {
            compress.write(buffer, 0, length);
        }
    } finally {
        LauncherUtils.close(bis);
        LauncherUtils.close(fis);
        LauncherUtils.close(compress);
        LauncherUtils.close(bos);
        LauncherUtils.close(fos);
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) Encoder(lzma.sdk.lzma.Encoder) FileOutputStream(java.io.FileOutputStream) LzmaOutputStream(lzma.streams.LzmaOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) FileInputStream(java.io.FileInputStream)

Aggregations

BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 Encoder (lzma.sdk.lzma.Encoder)1 LzmaOutputStream (lzma.streams.LzmaOutputStream)1