Java ByteArrayOutputStream.reset()
Syntax
ByteArrayOutputStream.reset() has the following syntax.
public void reset()
Example
In the following code shows how to use ByteArrayOutputStream.reset() method.
/*from w ww. j a va 2s. co m*/
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(75);
String str = baos.toString();
System.out.println("Before Resetting : " + str);
baos.reset();
baos.write(65);
str = baos.toString();
System.out.println("After Resetting : " + str);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »