Incompatible types. Found: 'java.io.File', required: 'java.lang.String' Unhandled exception: java.io.FileNotFoundException Unhandled exception: java.io.IOException #125711
Replies: 3 comments
This comment was marked as off-topic.
This comment was marked as off-topic.
-
Hi, can you please specify at which line the specified error is occurring? Again in line 18, we cannot check equality of strings using '==' operator. Instead, you can use .equals() function. In the catch block we should catch Exception not error. I hope you will find this useful. |
Beta Was this translation helpful? Give feedback.
-
In the line this.Password = new File(fileLocation);, you're trying to assign a File object to a String type (Password). This is causing the Incompatible types error. Instead, you should read the content of the file as a String. You are using FileReader without handling the FileNotFoundException and IOException. These exceptions should be either handled or declared in the method signature. //Note |
Beta Was this translation helpful? Give feedback.
-
Body
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions