Java StringBufferInputStream reset() Example
StringBufferInputStream class reset() method example. This example shows you how to use reset() method.
Syntax is : public void reset()
This method resets the input stream to begin reading from the first character of this input stream's underlying buffer. This is deprecated method.
Here is the code.
/**
* @(#) ResetStringBufferInputStream.java
* A class representing use of method reset() of StringBufferInputStream
class in java.io Package. This is deprecated class in java 1.6 API.
* @Version 29-May-2008
* @author Rose India Team
*/
import java.io.*;
public class ResetStringBufferInputStream {
public static void main(String[] args)throws Exception{
// Create object of StringBufferInputStream class
StringBufferInputStream obj = new StringBufferInputStream("Mahendra");
// read() method call. This is deprecated method in java 1.6 API.
System.out.println("First character of the buffer : "+(char)obj.read());
System.out.println("Next character of the buffer : "+(char)obj.read());
System.out.println("Next character of the buffer : "+(char)obj.read());
// reset() method call. This is deprecated method in java 1.6 API.
obj.reset();
System.out.println("After reset the buffer,next character is : "
+(char)obj.read());
}
} |
Output of the program.
First character of the buffer : M
Next character of the buffer : a
Next character of the buffer : h
After reset the buffer,next character is : M |
|