You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reading the File works when app is executed from the IDE, but if you compile and execute:
javac Main.java
java Main
then it throws:
Exception in thread "main" java.lang.IllegalArgumentException: File: app.log not found.
at ResourceHelper.getAbsoluteFilePath(ResourceHelper.java:11)
at Main.main(Main.java:15)
ResourceHelper.java:
public class ResourceHelper {
public static String getAbsoluteFilePath(String filename) {
URL resource = ClassLoader.getSystemClassLoader().getResource(filename);
if (resource == null) {
throw new IllegalArgumentException("File: " + filename + " not found.");
}
try {
Path path = Paths.get(resource.toURI());
return path.toString();
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e.getMessage());
}
}
}
Any suggestion to solve this?
The text was updated successfully, but these errors were encountered:
Reading the File works when app is executed from the IDE, but if you compile and execute:
then it throws:
ResourceHelper.java:
Any suggestion to solve this?
The text was updated successfully, but these errors were encountered: