logo

Java의 Java.util.zip.DeflaterOutputStream 클래스

Java의 Java.util.zip.DeflaterInputStream 클래스 이 클래스는 'deflate' 압축 형식으로 데이터를 압축하기 위한 출력 스트림 필터를 구현합니다. 또한 GZIPOutputStream과 같은 다른 유형의 압축 필터의 기초로도 사용됩니다. 생성자 및 설명
    DeflaterOutputStream(OutputStream 출력) :기본 압축기와 버퍼 크기를 사용하여 새 출력 스트림을 만듭니다. DeflaterOutputStream(OutputStream 출력 부울 syncFlush) :기본 압축기, 기본 버퍼 크기 및 지정된 플러시 모드를 사용하여 새 출력 스트림을 만듭니다. DeflaterOutputStream(OutputStream 출력 디플레이터 def):지정된 압축기와 기본 버퍼 크기를 사용하여 새 출력 스트림을 만듭니다. DeflaterOutputStream(OutputStream out DeFlater def boolean syncFlush) :지정된 압축기 플러시 모드와 기본 버퍼 크기를 사용하여 새 출력 스트림을 만듭니다. DeflaterOutputStream(OutputStream out Deflator def int size) :지정된 압축기 및 버퍼 크기를 사용하여 새 출력 스트림을 만듭니다. DeflaterOutputStream(OutputStream out DeFlater def int size boolean syncFlush):지정된 압축기 버퍼 크기와 플러시 모드를 사용하여 새 출력 스트림을 만듭니다.
행동 양식:
    무효 닫기() : Writes remaining compressed data to the output stream and closes the underlying stream.
      Syntax :  public void close() throws IOException   Overrides:   close in class FilterOutputStream   Throws:   IOException
    보호된 무효 deflate(): Writes next block of compressed data to the output stream.
      Syntax :  protected void deflate() throws IOException   Throws:   IOException
    무효 마무리() : Finishes writing compressed data to the output stream without closing the underlying stream.
      Syntax :  public void finish() throws IOException   Throws:   IOException
    무효 플러시() : Flushes the compressed output stream.
      Syntax :  public void flush() throws IOException   Overrides:   flush in class FilterOutputStream   Throws:   IOException
    void write(byte[] b int off int len) : Writes an array of bytes to the compressed output stream.
      Syntax :  public void write(byte[] b int off int len) throws IOException   Overrides:   write in class FilterOutputStream   Parameters:   b - the data to be written off - the start offset of the data len - the length of the data   Throws:   IOException
    무효 쓰기(int b) : Writes a byte to the compressed output stream.
      Syntax :  public void write(int b) throws IOException   Overrides:   write in class FilterOutputStream   Parameters:   b - the byte to be written   Throws:   IOException
Java
//Java program to demonstrate DeflaterOutputStream import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.zip.DeflaterOutputStream; class DeflaterOutputStreamDemo {  public static void main(String[] args) throws IOException   {  FileOutputStream fos = new FileOutputStream('file2.txt');  //Assign FileOutputStream to DeflaterOutputStream  DeflaterOutputStream dos = new DeflaterOutputStream(fos);  //write it into DeflaterOutputStream  for (int i = 0; i <10 ; i++)   {  dos.write(i);  }    //illustrating flush() method()  dos.flush();    //illustrating finish()  //Finishes writing compressed data to the output stream  // without closing the underlying stream  dos.finish();    //fos is not closed  //writing some data on file  fos.write('G');    //Writes remaining compressed data to the output stream  // closes the underlying stream.  dos.close();  } } 
메모: 여기서는 file2.txt를 읽을 수 없으므로 프로그램 출력은 온라인 IDE에 표시되지 않습니다. 퀴즈 만들기