开发者

Changing absolute paths in my code (mac) to relative paths for my pc

I have a netbeans project setup with the following absolute paths pointing to files on my harddrive.

/Users/Name/NetBeansProjects/DissertationUpnpDevices/src/my/upnpdevices/MSXbox360Device.java
/Users/Name/NetBeansProjects/DissertationUpnpDevices/src/my/upnpdevices/resources/description/MS_Xbox360description.xml

I will be moving my project over to a pc and I've be开发者_高级运维en trying to convert the above paths into relative paths. But it's not working out for me. So far I have tried:

private final static String DESCRIPTION_FILE_NAME = "resources\description\MS_Xbox360\description.xml";
private final static String DESCRIPTION_FILE_NAME = "resources\/description\/MS_Xbox360\/description.xml";

But the above 2 attempts don't work. They give me an 'illegal escape character' error. I have also tried the following below

private final static String DESCRIPTION_FILE_NAME = "resources/description/MS_Xbox360/description.xml";
private final static String DESCRIPTION_FILE_NAME = "resources//description//MS_Xbox360//description.xml";
private final static String DESCRIPTION_FILE_NAME = "resources\\description\\MS_Xbox360\\description.xml";
private final static String DESCRIPTION_FILE_NAME = "./resources/description/MS_Xbox360/description.xml";
private final static String DESCRIPTION_FILE_NAME = ".//resources//description//MS_Xbox360//description.xml";
private final static String DESCRIPTION_FILE_NAME = ".\\resources\\description\\MS_Xbox360\\description.xml";

These all give me "java.io.FileNotFoundException". Any other suggestions as to how I can convert the absolute mac URI to a relative URI for my pc? The files on the pc are setup in the corresponding directories.


Most of the paths you have above should work fine for you (specific'./resources/description/MS_Xbox360/description.xml'). I just got done with a project and the Mac version didn't like relative paths with '\\' so I changed them to '/' and everything works fine now. Also, the java.io.FileNotFoundException should print out what file it's looking for. Inspect the error closely and make sure the file actual does or doesn't exist.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜