1 30 31 32 package org.hsqldb.scriptio; 33 34 import java.io.IOException ; 35 import java.util.zip.Deflater ; 36 import java.util.zip.DeflaterOutputStream ; 37 38 import org.hsqldb.Database; 39 import org.hsqldb.HsqlException; 40 import org.hsqldb.Trace; 41 import org.hsqldb.lib.FileAccess; 42 43 49 class ScriptWriterZipped extends ScriptWriterBinary { 50 51 private static final int bufferSize = 1 << 15; 52 53 ScriptWriterZipped(Database db, String file, boolean includeCached, 54 boolean newFile) throws HsqlException { 55 super(db, file, includeCached, newFile); 56 } 57 58 61 public void sync() {} 62 63 protected void openFile() throws HsqlException { 64 65 try { 66 FileAccess fa = database.getFileAccess(); 67 java.io.OutputStream fos = fa.openOutputStreamElement(outFile); 68 69 outDescriptor = fa.getFileSync(fos); 70 fileStreamOut = new DeflaterOutputStream (fos, 71 new Deflater (Deflater.DEFAULT_COMPRESSION), bufferSize); 72 } catch (IOException e) { 73 throw Trace.error(Trace.FILE_IO_ERROR, Trace.Message_Pair, 74 new Object [] { 75 e.toString(), outFile 76 }); 77 } 78 } 79 80 84 protected void finishStream() throws IOException { 85 ((DeflaterOutputStream ) fileStreamOut).finish(); 86 fileStreamOut.flush(); 87 } 88 } 89 | Popular Tags |