As computer users we are familiar with the response computer programs have from user input and output. This lesson helps show the flip side of how programmers can code a Java program that considers, interprets, and responds to input and output.
Java is a powerful programming language that provides us with many ways to read input and write output to consoles, files, etc. In this lesson, we will learn about some of the built-in classes that are useful for completing these tasks. Some of these classes include:
Class | Definition | |||
---|---|---|---|---|
System.out |
A class that holds functions to display out in a terminal or command prompt application. | |||
Scanner |
A class used to read input passed into a Java program. | |||
FileOutputStream |
A class that holds functions to convert byte data into readable text files. | |||
FileInputStream |
A class that has functions that convert input from files to byte data for a Java program to use. |
We will also learn how to handle potential exceptions that occur due to input and output in a Java program. By the end of this lesson, we will have successfully run a Java program through the terminal!
Instructions
Review the table to gain a high-level understanding of each class’s purpose, then move on to the next exercise!