Here's the class
import java.io.*; public class MyIO { void printFile(String fileName) { BufferedReader rd; String line; try { rd = new BufferedReader(new FileReader(fileName)); while ((line = rd.readLine() ) != null) { System.out.println(line); } rd.close(); } catch (final IOException e) { System.out.println("Error reading file"); } } }
All along with an example usage:
MyIO myIO = new MyIO(); myIO.printFile("filename.txt");