I've run into a bit of code where an absolute path is being treated as relative. So far I've been unable to reproduce this in other projects.
I'm using NetBeans 8.0.2 with JDK 8u51 on Windows 10.
Here's the bit of code:
public void setImagePath(String path) throws IOException {
File file = new File(path);
System.out.printf("path: %s\n", path);
System.out.printf("resolved: %s\n", file.getAbsolutePath());
System.out.printf("test: %s\n", new java.io.File("C:/users/rando/desktop/test.jpg").getAbsolutePath());
img = ImageIO.read(file);
reloadImage();
}
And here's the output:
path: C:\users\rando\desktop\test.jpg
resolved: C:\Users\rando\Dropbox\Other\NetBeans Projects\Applications\test\C:\users\rando\desktop\test.jpg
test: C:\users\rando\desktop\test.jpg
Notice that halfway through the "resolved" line, it begins the absolute path with C:...
Can anyone shed any light on this?
My only guess is that this is a Windows 10 issue.
EDIT:
So, in a way, it is a Windows 10 issue. On Windows 7 I would always obtain the full path to a particular file by going to its properties and copying the object name from the security tab. In Windows 10 it apparently now has an additional control character.
Looks like you have a Unicode LRE control code in your path string. The easiest fix is
path = path.replaceAll("\\p{C}", "");
which will remove all control characters.