0% found this document useful (0 votes)
2 views30 pages

Understanding Java I/O Streams

Java I/O streams are sequences of data used for reading from sources and writing to destinations, classified into byte and character streams. The document discusses various classes related to input and output streams, including InputStream, OutputStream, FileInputStream, and FileOutputStream, along with methods like available(), skip(), write(), and flush(). An example code snippet demonstrates the use of FileOutputStream to write data to a file.

Uploaded by

sanjithbadri123
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views30 pages

Understanding Java I/O Streams

Java I/O streams are sequences of data used for reading from sources and writing to destinations, classified into byte and character streams. The document discusses various classes related to input and output streams, including InputStream, OutputStream, FileInputStream, and FileOutputStream, along with methods like available(), skip(), write(), and flush(). An example code snippet demonstrates the use of FileOutputStream to write data to a file.

Uploaded by

sanjithbadri123
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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]");
}

You might also like