Java I/O Streams
• In Java, streams are the sequence of data that are read from the
source and written to the destination.
• An input stream is used to read data from the source. And, an output
stream is used to write data to the destination.
class HelloWorld {
public static void main(String[] args) {
[Link]("Hello, World!");
}
}
Types of Streams
Depending upon the data a stream holds, it can be classified into:
•Byte Stream
•Character Stream
Byte Stream and Character Stream
Java InputStream Class
Java OutputStream Class
OutputStream Using FileOutputStream
Java FileInputStream Class
Create a FileInputStream
Methods of FileInputStream
available() Method
skip() Method
Java FileOutputStream Class
import [Link]; // Using write() method
import [Link]; [Link]([Link]());
public class Main { // Using the flush() method
public static void main(String[] args) throws [Link]();
IOException {
[Link]();
}
FileOutputStream out = null; catch(Exception e) {
String data = "This is demo of flush method";
[Link]();
}
try { }
out = new FileOutputStream(" [Link]");
}