public static PrintWriter openScriptWriter(String fileName,String compressionAlgorithm,String cipher,String password,String charset) throws IOException {
  try {
    OutputStream out;
    if (cipher != null) {
      byte[] key=SHA256.getKeyPasswordHash("script",password.toCharArray());
      FileUtils.delete(fileName);
      FileStore store=FileStore.open(null,fileName,"rw",cipher,key);
      store.init();
      out=new FileStoreOutputStream(store,null,compressionAlgorithm);
      out=new BufferedOutputStream(out,Constants.IO_BUFFER_SIZE_COMPRESS);
    }
 else {
      out=FileUtils.newOutputStream(fileName,false);
      out=new BufferedOutputStream(out,Constants.IO_BUFFER_SIZE);
      out=CompressTool.wrapOutputStream(out,compressionAlgorithm,"script.sql");
    }
    return new PrintWriter(new OutputStreamWriter(out,charset));
  }
 catch (  Exception e) {
    throw new IOException(e.getMessage(),e);
  }
}

public static PrintWriter openScriptWriter ( String fileName , String compressionAlgorithm , String cipher , String password , String charset ) throws IOException { try { OutputStream out ; if ( cipher != null ) { byte [ ] key = SHA256 . getKeyPasswordHash ( "script" , password . toCharArray ( ) ) ; FileUtils . delete ( fileName ) ; FileStore store = FileStore . open ( null , fileName , "rw" , cipher , key ) ; store . init ( ) ; out = new FileStoreOutputStream ( store , null , compressionAlgorithm ) ; out = new BufferedOutputStream ( out , Constants . IO_BUFFER_SIZE_COMPRESS ) ; } else { out = FileUtils . newOutputStream ( fileName , false ) ; out = new BufferedOutputStream ( out , Constants . IO_BUFFER_SIZE ) ; out = CompressTool . wrapOutputStream ( out , compressionAlgorithm , "script.sql" ) ; } return new PrintWriter ( new OutputStreamWriter ( out , charset ) ) ; } catch ( Exception e ) { throw new IOException ( e . getMessage ( ) , e ) ; } }
open a script writer .
