reset(): This method is available in the java.io.ByteArrayOutputStream class of Java.
Syntax:
void java.io.ByteArrayOutputStream.reset()
This method resets the count field of this ByteArrayOutputStreamto zero so that all currently accumulated output in the output stream is discarded.
The output stream can be used again, reusing the already allocated buffer space.
Parameters: NA
Returns: NA
Exceptions: NA
Approach
Java
import java.io.ByteArrayOutputStream;import java.io.IOException;public class ByteArrayOutputStreamreset {public static void main(String[] args) throws IOException {int size = 5;ByteArrayOutputStream byteArrayOutputStream =new ByteArrayOutputStream(size);byteArrayOutputStream.reset();System.out.println("Successfully reset the buffer");byteArrayOutputStream.close();}}
Output:
Successfully reset the buffer
No comments:
Post a Comment