How do I specifiy a path to a file in Java?
Ok this is a homework questions, but I cannot fi开发者_如何学Gond 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?
Try using double back-slashes. (\\)
However, the more portable solution is to use File.separator, as described here.
By the way, "/" works on all platforms.
Use File.separator
.
This depends on the platform - on windows, it'll be replaced by 'c:\', on Unix it'll be left as '/'
精彩评论