How to open and read a text file in Java (FileReader, BufferedReader)

Java File I/O FAQ: How do I open a file and read text from it using Java? (Also written as, “How do I use the Java BufferedReader and FileReader classes to read from a text file?”)

Solution: Here’s a method taken from a Java class I wrote that shows how to open and read a file using the Java FileReader class. This uses the most recent Java syntax and classes.