Java Part 5: Input And Output Operations
(Page 1 of 4 )
In this article, Chris will continue his popular "Java How-To" series and teach us all how to create a simple Java application that will read a file and output its contents to the screen.Just like many other object-orientated programming languages, Java contains built in classes that we can instantiate throughout our applications. These allow us to use pre-created and tested modules, without having to re-invent the wheel every time we want to perform some common task, such as reading from or writing to a file.
In this article, I will continue down the road to learning Java and discuss how to create a simple Java application that will read a file and output its contents (line-by-line) to the screen. The application that I will discuss is essentially based on the Unix/Linux shell command "cat", which takes the name of a file from the command line and outputs the entire contents of that file to the display.
This article will also build on using classes and objects, as discussed in part 4 of this series. You should be familiar with Java basics (Parts 1, 2, 3 and 4 of this series) to get the most from this tutorial.
Next: Our file I/O application explained >>
More Java Articles
More By Chris Noack