File not getting workspace
Hi! (Sorry for the bad title. English is not my native language and I didn't know how to put it.) I have a problem with getting an image with ImageIO.read(File file). I have the following code to get the image.
Code java:
try {
File file = new File("/res/entities/player/human.png");
System.out.println(file.getAbsolutePath());
image = ImageIO.read(file);
} catch (IOException e) {
e.printStackTrace();
}
The problem is, the file does not get the workspace path before the given path.
Instead of the path being:
C:/...path to workspace.../res/entities/player/human.png
It is:
C:/res/entities/player/human.png
This has never happened before and I dont know what to do.
There error is also only in this program. It works in all my other projects!
Please help me!
Re: File not getting workspace
Try
Code :
File file = new File("res/entities/player/human.png");
ie without the leading /. At the moment the file name will be resolved to something at the top of the current drive (C).
Re: File not getting workspace
Re: File not getting workspace