views:

87

answers:

4

Ok this is a homework questions, but I cannot find the answer anywhere, not even in the book.

Path to Files If the user wants to specify a path for a file, the typical forward slash is replaced by ________.

can you help?

+1  A: 

Try using double back-slashes. (\\)

However, the more portable solution is to use File.separator, as described here.

ElectricDialect
Java should automatically convert forward-slashes in file paths to back-slashes if the OS (Windows) so requires, so I don't think that the question is about that.
Esko Luontola
A: 

This depends on the platform - on windows, it'll be replaced by 'c:\', on Unix it'll be left as '/'

jayshao
+1  A: 

By the way, "/" works on all platforms.

ring bearer
What is "all platforms"? Java runs on a LOT more than Windows, Linux and OS X. You have NO guarantee that / works on other platforms that your code might one day run on.
Matt Olenik
For the sake of argument, the question is from a file system stand point, that too on Windows. I just meant popular OSs when I said "all platforms" - Unfortunately your java skills in one device platform(say, server/desktop) does not hold good for other devices (mobile/embedded)
ring bearer
A: 

Use File.separator.

Steve Kuo