Java.util.zip.DeflaterInputStream class in Java Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Implements an input stream filter for compressing data in the "deflate" compression format. Constructor and Description DeflaterInputStream(InputStream in) : Creates a new input stream with a default compressor and buffer size. DeflaterInputStream(InputStream in, Deflater defl) : Creates a new input stream with the specified compressor and a default buffer size. DeflaterInputStream(InputStream in, Deflater defl, int bufLen) :Creates a new input stream with the specified compressor and buffer size. Methods: int available() : Returns 0 after EOF has been reached, otherwise always return 1. Syntax :public int available() throws IOException Parameters: n - number of bytes to be skipped Returns: the actual number of bytes skipped Throws: IOException void close() : Closes this input stream and its underlying input stream, discarding any pending uncompressed data. Syntax :public void close() throws IOException Overrides: close in class FilterInputStream Throws: IOException void mark(int limit) : This operation is not supported. Syntax :public void mark(int limit) Parameters: limit - maximum bytes that can be read before invalidating the position marker boolean markSupported() : Always returns false because this input stream does not support the mark() and reset() methods. Syntax :public boolean markSupported() Returns: false, always int read() : Reads a single byte of compressed data from the input stream. Syntax :public int read() throws IOException Returns: a single byte of compressed data, or -1 if the end of the uncompressed input stream is reached Throws: IOException int read(byte[] b, int off, int len) : Reads compressed data into a byte array. Syntax :public int read(byte[] b, int off, int len) throws IOException Parameters: b - buffer into which the data is read off - starting offset of the data within b len - maximum number of compressed bytes to read into b Returns: the actual number of bytes read, or -1 if the end of the uncompressed input stream is reached Throws: IndexOutOfBoundsException IOException void reset() : This operation is not supported. Syntax :public void reset() throws IOException Throws: IOException long skip(long n) : Skips over and discards data from the input stream. Syntax :public long skip(long n) throws IOException Parameters: n - number of bytes to be skipped Returns: the actual number of bytes skipped Throws: IOException Program: Java //Java program to illustrate DeflaterInputStream class import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.zip.DeflaterInputStream; class DeflaterInputStreamDemo { public static void main(String[] args) throws IOException { byte b[] = new byte[10]; for (byte i = 0; i <10 ; i++) { b[i] = i; } ByteArrayInputStream bin = new ByteArrayInputStream(b); DeflaterInputStream din = new DeflaterInputStream(bin); //illustrating markSupported() method System.out.println(din.markSupported()); //illustrating skip() method din.skip(1); //illustrating available() method System.out.println(din.available()); //illustrating read(byte[] b,int off,int len) byte c[] = new byte[10]; din.read(c,0,9); for (int i = 0; i < 9; i++) { System.out.print(c[i]); } while(din.available() == 1) { //Reads a single byte of compressed data System.out.print(din.read()); } System.out.println(); System.out.println(din.available()); // illustrating close() method din.close(); } } Output : false 1 -1009996100981029710199231224400175046-1 0 The above output represents compressed data. Next Article: Java.util.zip.DeflaterOutputStream class in Java Create Quiz Comment K kartik 0 Improve K kartik 0 Improve Article Tags : Java Java-I/O Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings7 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java5 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages2 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java4 min readJava Comparator Interface5 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java7 min readFile Handling in Java4 min readJava Method References7 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management3 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers1 min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like