A computer can be described as an electronic machine that processes data. At a fundamental level a computer simply accepts input, performs some processing, and produces output. As an example, consider how a computer is used to perform the payroll functions for a small business.
The processing that takes place is the calculation of the pay due each employee. The input to this process is the number of hours worked and rate of pay for each employee, and the output is the employee checks.
The following diagram illustrates this model.
When we talk about input and output in computing, we describe all forms of communication between a program on the computer and the outside world
, which includes human end users, other programs on the same machine, or other programs running on other computers. Input includes all the data and signals received by the running program. For instance, input can be sent to a program using input devices such as a keyboard or mouse, or can come from other computers, such as when you use your web browser to load in a specific web page.
Output on the other hand includes all the signals and data sent from a program. Monitors and printers are prime examples of output devices, but again, output can involve pure data, such as when your web browser sends a request to a web server to receive a web page. The latter immediately illustrates that the same program (a web browser) can involve a series of input and output operations. The same holds for hardware devices, such as a network card or a modem. A particular form of I/O we will be taking a closer look at in this chapter is file I/O, meaning input and output operations that read and write data to files stored on your computer. We can skip the details until we are ready to start dealing with files in Java, but two aspects are worth mentioning:
- file modes and
- the difference between text and binary files as they apply to programming languages other than Java.