Read from a file using a BufferedReader
import java.io.BufferedReader; import java.io.FileReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader bufferedReader = new BufferedReader(new FileReader("yourFile.txt")); String line = null; while ((line = bufferedReader.readLine()) != null) { System.out.println(line); } bufferedReader.close(); } }