available(): This method is available in java.io.ByteArrayInputStream class of Java.
Syntax:
int java.io.ByteArrayInputStream.available()
This method returns the number of remaining bytes that can be read (or skipped over) from this input stream.
Parameters: NA
Returns: the number of remaining bytes that can be read (or skipped over) from this input stream without blocking.
Exceptions: NA
Approach
Java
import java.io.ByteArrayInputStream;import java.io.IOException;public class ByteArrayInputStreamavailable {public static void main(String[] args) throws IOException {byte buf[] = { 1, 2, 3, 4 };ByteArrayInputStream byteArrayInputStream =new ByteArrayInputStream(buf);System.out.println(byteArrayInputStream.available());byteArrayInputStream.close();}}
Output:
4
No comments:
Post a Comment