Deflater setInput() function in Java with examples
The setInput() function of the Deflater class in java.util.zip is used to set input data for compression. This function should be called when needsInput() returns true indicating input buffer is empty.
public void setInput(byte b) public void setInput(byte b, int offset, int len)
d.setInput(byte); d.setInput(byte, int, int);
Parameter: The various parameters accepted by these overloaded functions are:
- byte b: This is the input array that is to be deflated
- int offset: This is the starting offset from which the values are to be read in the given array
- int length: This is the maximum length to be compressed from the starting offset.
Return Type: The function has do not return anything.
Exception: The function does not throw any exception
Compressed String :x?sOM?.N?/r???q?? Size 21 Original String :GeeksforGeeksGeeksforGeeksGeeksforGeeksGeeksforGeeks Size 52
Compressed String :x?K?.vOM?.N?/???? Size 22
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.