bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java I/O Streams
Java•Java I/O Streams

Java I/O Streams

Flash cards

Review the key moves

1/3
Core idea

What is the main idea behind Java I/O Streams?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Order

Put the learning moves in the order that makes the concept easiest to apply.

In Java, there is an important difference between working with the File class and working with I/O Streams (Input/Output Stream):
You've already seen how to create, read, and write simple text files.
I/O Streams (Input/Output Streams)

I/O Streams (Input/Output Streams)

You've already seen how to create, read, and write simple text files.

In Java, there is an important difference between working with the File class and working with I/O Streams (Input/Output Stream):

  • The File class (from java.io ) is used to get information about files and directories : Does the file exist? What is its name or size? Create or delete files and folders But: the File class does not read or write the contents of the file.
  • Does the file exist?
  • What is its name or size?
  • Create or delete files and folders

So far, we have used FileWriter for writing text and Scanner for reading text. These are easy to use, but they are mainly designed for simple text files .

I/O Streams are more flexible, because they work with text and binary data (like images, audio, PDFs).

Types of Streams

  • Byte Streams Work with raw binary data (like images, audio, and PDF files). Examples: FileInputStream , FileOutputStream .
  • Character Streams Work with text (characters and strings). These streams automatically handle character encoding. Examples: FileReader , FileWriter , BufferedReader , BufferedWriter .

Tip

Use character streams when working with text, and byte streams when working with binary data.

Next

Java FileInputStream