Levenlol
Levenlol

Reputation: 415

Java absolute path - Mac OS X - Windows

I'm about to release an java application but I have a little problem: I've completely developed the app on Mac OS X via eclipse and I use an absolute path to refer to a directory placed in:

"/Users/Name/Documents/folder"

I used System.getProperty"os.name" to find out if i'm currently running on a mac or not, and if it is, I will use that folder, else I will use another folder example: C:\Users\Name\Documents\folder.

The problem is: I have to append to this string a name that may contain other subfolder. I know that on mac to separate folder i use "/" and on windows "\". How can i solve that issue ? any tips ?

Upvotes: 1

Views: 3530

Answers (1)

Patrick
Patrick

Reputation: 831

You can use the following to have the good separator :

System.getProperty("file.separator")

Upvotes: 2

Related Questions