Java Byte Stream Classes
I/O Streams
A Stream is a path of communication between the source and destination of data. A stream is linked to a physical device by the java I/O stream Java defined two types of streams: Byte streams and character streams.
Byte Stream classes
Byte streams handle input and output of bytes.
Byte streams are defined two class hierarchies:InputStream and
OutputStream(abstract classes)
Each of these abstract classes has several subclasses.
Byte stream has two important methods: read() and write().
Character Stream classes
Character stream handles input and output of streams.
Character stream are defined two class hierarchies: Reader and writer(abstract classes).
Character stream has two important methods:Read() and write().
Byte Stream Classes
The most commonly used byte stream classes are: Input Stream and Output Stream classes. Input Stream classes are Buffered Input Stream, Byte Array Input Stream, Daa Input Stream, File Input Stream, Piped Input Sream, Object Input Stream, Sequence Input Stream, Push back Input Stream etc.
Output Stream classes are Buffer Output Stream, Byte Array Output Stream, Data Output Stream, File OutputStream, PipedOutputStream, ObjectOutputStream, PushOutputStream etc.
example 1:
Output :
Number of available bytes: 24 Number of skipped bytes: 11 String after skipping s bytes: first program String in uppercase: THIS IS MY FIRST PROGRAM
example 2:
Output :
Exception in thread "main" java.security.AccessControlException: access denied ("java.io.FilePermission" "sorcefile.txt" "read") at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) at java.security.AccessController.checkPermission(AccessController.java:884) at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) at java.lang.SecurityManager.checkRead(SecurityManager.java:888) at java.io.FileInputStream.(FileInputStream.java:127) at java.io.FileInputStream. (FileInputStream.java:93) at BStream.main(BStream.java:13)