Java StringBufferInputStream read() Example
StringBufferInputStream class read() method example. This example shows you how to use read() method.
Syntax is : public int read(byte[] b, int off, int len)
Method reads up to len bytes of data from this input stream into an array of bytes. This is deprecated method.
Here is the code.
/**
* @(#) Read1StringBufferInputStream.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 Read1StringBufferInputStream {
public static void main(String[] args){
byte[] arrByte = new byte[10];
// 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(arrByte, 2, 5);
System.out.println("The total number of bytes read into the buffer : "
+byteCount);
}
} |
Output of the program.
| The total number of bytes read into the buffer : 5 |
|