Java StringBufferInputStream available() Example
StringBufferInputStream class available() method example. This example shows you how to use available() method.
Syntax is : public int available()
Method returns the number of bytes that can be read from the input stream without blocking. This is deprecated method.
Here is the code.
/**
* @(#) AvailableStringBufferInputStream.java
* A class representing use of method available() 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 AvailableStringBufferInputStream {
public static void main(String[] args){
// Create object of StringBufferInputStream class
StringBufferInputStream obj = new StringBufferInputStream("Mahendra");
// available() method call. This is deprecated method in java 1.6 API.
int byteCount = obj.available();
System.out.println("number of bytes that can be read from the "
+" input stream : " + byteCount);
}
} |
Output of the program.
| number of bytes that can be read from the input stream : 8 |
|