Answer the question
In order to leave comments, you need to log in
How to get the file correctly?
I do like this:
File cageFrom = new File(File.separator + "home" + File.separator + "SkyWarsUtils", "Cages");
java.io.FileNotFoundException: /home/SkyWarsUtils/Cages (No such file or directory)
?
Answer the question
In order to leave comments, you need to log in
I figured it out myself an hour ago)
If the files are in the root of the project, remove the slash at the beginning.
You can also take files/streams from resources:
+ As Alexey already said, Path is more convenient. App.class.getClassLoader().getResource("filename")
It is not clear why you are inserting file.separator, you still have an absolute path. You can write at once:
In your case you still call StringBuilder implicitly.
But you can do even better - use a relative path:
Such a file will refer to the Cages file in the project folder.
File file = new File("/home/SkyWarsUtils/Cages");
File file = new File("./Cages");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question