A way to convert path file from Linux to window?
HelloI have a path file from database under Linux path/folder1/subfolder1/subfolder2/myFile.txtIs there simple way to change this path to Window pathThanks
[190 byte] By [
suhua] at [2007-11-27 8:56:52]

That is an acceptable path on Windows.
> That is an acceptable path on Windows.Yep.Anyway, you can use path.replace('/', '\\')
> > That is an acceptable path on Windows.> > Yep.> > Anyway, you can use path.replace('/', '\\')Why would you want to do that?
Thank flownder for your help
my file has two paths. the last path from database under Linux path with "/" and the first path is from computer. If it is Linux, I will enter /home/balalal/ for the first path and then add this path with the last path from database. Everything fine.
If the computer is Window, I need to change the first path to something like C:\\dsfsdf\\blabla and then add this first path to the last path from database. However, the last path is Linux path
There is simple way to overcome this
Thanks again
suhua at 2007-7-12 21:20:30 >

So?String windowsPath = "C:/blah/blah";String linuxPath = // get details from database.String fullPath = windowsPath + linuxPath;
Really, so simple ?I build the application in Linux and need to test in Window as wellI will try thisthanks
suhua at 2007-7-12 21:20:30 >

> > > That is an acceptable path on Windows.
> >
> > Yep.
> >
> > Anyway, you can use path.replace('/', '\\')
>
> Why would you want to do that?
I don't know, I tought maybe he want to Print the path....
however
The pseudocode was posted must works
If you want that the path get \ instead /, use:
String windowsPath = "C:\\dsfsdf\\blabla";
String linuxPath = "/example/path"
String fullPath = windowsPath + linuxPath.replace('/', '\\');
SIGH! Leave the frigging slashes as /. That way it doesn't matter which platform it is run on it will work.
String only have function replaceAll and when I run, there is error:
Here is my code:
String aPath = "abc/abad/aafd.jpg";
String newPath = path.replaceAll("/", "\\");
Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException
: String index out of range: 1
at java.lang.String.charAt(Unknown Source)
at java.util.regex.Matcher.appendReplacement(Unknown Source)
at java.util.regex.Matcher.replaceAll(Unknown Source)
at java.lang.String.replaceAll(Unknown Source
suhua at 2007-7-12 21:20:30 >

String newPath = path.replaceAll("/", "\\\\");
Thanks allBoth of those methods work
suhua at 2007-7-12 21:20:31 >

> when I run,Don't. See reply #8.
ejpa at 2007-7-12 21:20:31 >

The flownder's method is simple
suhua at 2007-7-12 21:20:31 >

Yep, I do not know how simple it is when using flownder's method
suhua at 2007-7-12 21:20:31 >

It's good to see my advice get ignored once again until someone reiterates it.BTW it's floUnder. U not W.
and then everybody reiterates it ...and the mis-spelling.
ejpa at 2007-7-21 22:51:09 >

No, I apply flounder's method before anyone reiterates it (post in 11 before 12)...However, the method "replace" is easy to understand with someone who is new to Java, so I tried it first.
suhua at 2007-7-21 22:51:09 >
