Why am i seeing 'ioexception in java'?

Example:

FileReader fr = new FileReader("nonexistent.txt");
Solution:

IOException is a general class of exception that represents an I/O operation failure. Always handle or declare this exception when dealing with I/O operations to ensure smooth execution.


try {
    FileReader fr = new FileReader("path.txt");
} catch(IOException e) {
    e.printStackTrace();
}

Beginner's Guide to Java