Java For Complete Beginners - Reading Text Files Manipulating text files is a skill that will serve you well in your programming career. In this section, you'll learn how to open and how to write to a text file. But by text file, we just mean a file with text in it - simple as that! The first thing we'll do is to open up a text file and read its contents. Read a Text File Start a new project for this. import java.io.IOException; Your coding window will then look like this: To deal with anything going wrong with our file handling, add the following to the main method (the text in bold): public static void main(String[ ] args) throws IOException { We're telling Java that the main method will throw up an IOException error, and that it has to be dealt with. To open the text file, let's create a new class. import java.io.IOException; import java.io.FileReader; import java.io.BufferedReader; Your new class should then look like this one: (The import lines are underlined because we haven't done anything with them yet. public String[ ] int i;