Java StringBufferInputStream read() Example

StringBufferInputStream class read() method example. This example shows you how to use read() method.


Syntax is : public int read()
Method reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This is deprecated method.

Here is the code.
/**
 * @(#) ReadStringBufferInputStream.java
 * A class representing use of method read() 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 ReadStringBufferInputStream {
     public static void main(String[] args){

    // Create object of StringBufferInputStream class
        StringBufferInputStream obj = new StringBufferInputStream("Mahendra");
    // read() method call. This is deprecated method in java 1.6 API.
    int byteCount = obj.read();
    System.out.println("Next byte of data from this input stream : "
    + byteCount);
    }
}

Output of the program.
Next byte of data from this input stream : 77

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US