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

Java I/O Streams Explained

Java I/O streams are sequences of data for reading from sources and writing to destinations, categorized into input and output streams. They can further be classified into byte streams and character streams, with specific classes like InputStream and OutputStream for handling data. The document also discusses methods for FileInputStream and FileOutputStream, including writing and flushing data to files.

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 PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views30 pages

Java I/O Streams Explained

Java I/O streams are sequences of data for reading from sources and writing to destinations, categorized into input and output streams. They can further be classified into byte streams and character streams, with specific classes like InputStream and OutputStream for handling data. The document also discusses methods for FileInputStream and FileOutputStream, including writing and flushing data to files.

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 PPTX, 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