How to read file in Java.

There are many available classes in the Java API that can be used to read and write files in Java: FileReader, BufferedReader, Files, Scanner etc.

Code :