فئة Java.util.zip.InflaterInputStream في Java

تطبق هذه الفئة مرشح دفق لفك ضغط البيانات بتنسيق الضغط "الانكماش". كما يتم استخدامه كأساس لمرشحات إلغاء الضغط الأخرى مثل GZIPInputStream. البنائين
    InflaterInputStream(InputStream in): يقوم بإنشاء دفق إدخال جديد باستخدام برنامج إلغاء الضغط الافتراضي وحجم المخزن المؤقت. InflaterInputStream (InputStream في Inflater inf): يقوم بإنشاء دفق إدخال جديد باستخدام برنامج إلغاء الضغط المحدد وحجم المخزن المؤقت الافتراضي. InflaterInputStream (InputStream في حجم Inflater inf int): يقوم بإنشاء دفق إدخال جديد باستخدام برنامج إلغاء الضغط وحجم المخزن المؤقت المحدد.
طُرق:
    العدد المتاح () : Returns 0 after EOF has been reached otherwise always return 1.
      Syntax :   public int available() throws IOException   Returns:   1 before EOF and 0 after EOF.   Throws:   IOException  
    إغلاق باطل () : Closes this input stream and releases any system resources associated with the stream.
      Syntax :   public void close() throws IOException   Throws:   IOException  
    ملء الفراغ المحمي (): Fills input buffer with more data to decompress.
      Syntax :   protected void fill() throws IOException   Throws:   IOException  
    علامة باطلة (حد القراءة الدولي): Marks the current position in this input stream.
      Syntax :   public void mark(int readlimit)   Parameters:   readlimit - the maximum limit of bytes that can be read before the mark position becomes invalid. 
    العلامة المنطقية المدعومة () : Tests if this input stream supports the mark and reset methods.
      Syntax :   public boolean markSupported() Returns: a boolean indicating if this stream type supports the mark and reset methods.  
    قراءة دولية (): Reads a byte of uncompressed data.
      Syntax :   public int read() throws IOException   Returns:   the byte read or -1 if end of compressed input is reached   Throws:   IOException 
    قراءة int (بايت [] ب int off int len): Reads uncompressed data into an array of bytes.
      Syntax :   public int read(byte[] b int off int len) throws IOException   Parameters:   b - the buffer into which the data is read off - the start offset in the destination array b len - the maximum number of bytes read   Returns:   the actual number of bytes read or -1 if the end of the compressed input is reached.   Throws:   NullPointerException IndexOutOfBoundsException ZipException IOException  
    إعادة تعيين باطلة (): Repositions this stream to the position at the time the mark method was last called on this input stream.
      Syntax :   public void reset() throws IOException   Throws:   IOException  
    تخطي طويل (طويل ن): Skips specified number of bytes of uncompressed data.
      Syntax :   public long skip(long n) throws IOException   Parameters:   n - the number of bytes to skip   Returns:   the actual number of bytes skipped.   Throws:   IOException IllegalArgumentException  
برنامج: Java
   //Java program to demonstrate InflaterInputStream   import     java.io.FileInputStream  ;   import     java.io.FileOutputStream  ;   import     java.io.IOException  ;   import     java.util.zip.DeflaterOutputStream  ;   import     java.util.zip.InflaterInputStream  ;   class   InflaterInputStreamDemo   {      public     static     void     main  (  String  []     args  )     throws     IOException      {      FileOutputStream     fos     =     new     FileOutputStream  (  'file.txt'  );      //Assign FileOutputStream to DeflaterOutputStream      DeflaterOutputStream     dos     =     new     DeflaterOutputStream  (  fos  );      //write it into DeflaterOutputStream      for     (  int     i     =     0  ;     i      <     10  ;     i  ++  )      {      dos  .  write  (  i  );      }      dos  .  flush  ();      dos  .  close  ();      FileInputStream     fis     =     new     FileInputStream  (  'file.txt'  );      InflaterInputStream     iis     =     new     InflaterInputStream  (  fis  );      //illustrating available() method      System  .  out  .  println  (  iis  .  available  ());      //illustrating mark and markSupported()      if     (  iis  .  markSupported  ())      iis  .  mark  (  15  );      else      System  .  out  .  println  (  false  );          //illustrating skip() method      iis  .  skip  (  3  );      //illustrating read()      for     (  int     i     =     0  ;     i      <  3     ;     i  ++  )         {      System  .  out  .  print  (  iis  .  read  ());      }      //illustrating read(byte[] bint offint len)      byte     b  []=  new     byte  [  4  ]  ;          for     (  int     i     =     0  ;     i      <  4     ;     i  ++  )         {      iis  .  read  (  b    0    4  );      }          for     (  int     i     =     0  ;     i      <     4  ;     i  ++  )         {      System  .  out  .  print  (  b  [  i  ]  );      }      }   }   
الإخراج:
1 false 3456789 
المقالة التالية: فئة Java.util.zip.InflaterOutputStream في Java إنشاء اختبار