Param-Ganak
Param-Ganak

Reputation: 5875

How to make the JFileChooser to return the file or directory path containing the forward slash in stead of backward slash in java?

I have implemented JFileChooser of Java swing successfully. As the implemented JFileChooser gives file or directory path with backward slash as a file separator on windows os. My question is how to make this JFileChooser to return the file or directory path containing the forward slash in stead of backward slash as path separator in java independent of windows os or any other os?

Please guide me Friends!

Thank You!

Upvotes: 1

Views: 1193

Answers (2)

Mister Smith
Mister Smith

Reputation: 28168

The File class actually abstracts you of this task. The JFileChooser return a File object, then you can call its getCanonicalPath method (for instance) which has a different format depending on the OS.

Upvotes: 1

michael667
michael667

Reputation: 3260

Normally, you don't have to care about forward/backward slashes. The JFileChooser will return the path so that it is suitable for the machine it is running on.

Upvotes: 3

Related Questions