I have a class FileLock, which checks and validates a file, and a method Validate
public class FileLock {
public static void Validate(String conf_file) throws IOException{
My intention is whenever an IOException is encountered, it should terminate.
Now I have the test class to test this.
public class Test{
public static void main(String[] args){
String conf_file = args[0];
FileLock.Validate(conf_file);
Now, this gives a compile time error saying Unhandled exception type IOException
at the line FileLock.Validate(conf_file);
If I add throws IOException
along with main()
as well, this error disappears. Why is that? What is the best way to do this?