I want to take a string representing a path and convert it to an absolute Unix-style path. This line can be in Windows or Unix styles, as this is the result of calling MainClass.class.getClassLoader().getResource("").getPath() , which returns different styles paths depending on your system.
(I do this for the game I am writing, the part of which gives the user a simple bash -ish shell, "and I want the user to read files. The fake file system is stored as a normal directory tree in a subdirectory of my project. This file system will use Unix-style paths, and I want to be able to concatenate the entered paths with the above line (with some minor changes to get it to the right of the directory), so I can find the contents of the files.)
Any ideas how I can do this? I tried several things, but I can not get it to work correctly on my Windows 7 system.
Right now, I'm just using a simple thing that checks if a line starts with "C: \" or something similar, and then replaces the backslash with a slash, but there is no way that this is a good way to go about it, and I am sure that other people have encountered the problem of different styles of the way before. This is certainly a very temporary solution.
source share