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]
# 1
That is an acceptable path on Windows.
floundera at 2007-7-12 21:20:30 > top of Java-index,Java Essentials,New To Java...
# 2
> That is an acceptable path on Windows.Yep.Anyway, you can use path.replace('/', '\\')
pbulgarellia at 2007-7-12 21:20:30 > top of Java-index,Java Essentials,New To Java...
# 3
> > That is an acceptable path on Windows.> > Yep.> > Anyway, you can use path.replace('/', '\\')Why would you want to do that?
floundera at 2007-7-12 21:20:30 > top of Java-index,Java Essentials,New To Java...
# 4

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 > top of Java-index,Java Essentials,New To Java...
# 5
So?String windowsPath = "C:/blah/blah";String linuxPath = // get details from database.String fullPath = windowsPath + linuxPath;
floundera at 2007-7-12 21:20:30 > top of Java-index,Java Essentials,New To Java...
# 6
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 > top of Java-index,Java Essentials,New To Java...
# 7

> > > 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('/', '\\');

pbulgarellia at 2007-7-12 21:20:30 > top of Java-index,Java Essentials,New To Java...
# 8
SIGH! Leave the frigging slashes as /. That way it doesn't matter which platform it is run on it will work.
floundera at 2007-7-12 21:20:30 > top of Java-index,Java Essentials,New To Java...
# 9

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 > top of Java-index,Java Essentials,New To Java...
# 10
String newPath = path.replaceAll("/", "\\\\");
CaptainMorgan08a at 2007-7-12 21:20:31 > top of Java-index,Java Essentials,New To Java...
# 11
Thanks allBoth of those methods work
suhua at 2007-7-12 21:20:31 > top of Java-index,Java Essentials,New To Java...
# 12
> when I run,Don't. See reply #8.
ejpa at 2007-7-12 21:20:31 > top of Java-index,Java Essentials,New To Java...
# 13
The flownder's method is simple
suhua at 2007-7-12 21:20:31 > top of Java-index,Java Essentials,New To Java...
# 14
Yep, I do not know how simple it is when using flownder's method
suhua at 2007-7-12 21:20:31 > top of Java-index,Java Essentials,New To Java...
# 15
It's good to see my advice get ignored once again until someone reiterates it.BTW it's floUnder. U not W.
floundera at 2007-7-21 22:51:09 > top of Java-index,Java Essentials,New To Java...
# 16
and then everybody reiterates it ...and the mis-spelling.
ejpa at 2007-7-21 22:51:09 > top of Java-index,Java Essentials,New To Java...
# 17
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 > top of Java-index,Java Essentials,New To Java...