Can FileOutputStream() take a relative path as an argument

Posted by Ankur on Stack Overflow See other posts from Stack Overflow or by Ankur
Published on 2010-04-07T06:55:39Z Indexed on 2010/04/07 7:03 UTC
Read the original article Hit count: 283

I am creating a FileOutputStream object. It takes a file or String as an argument in its constructor.

My question is, can I give it a relative URL as an argument for the location of a file, it doesn't seem to work, but I am trying to work out if this is possible at all (if not I will stop trying).

If it is not possible, how can I (from a servlet) get the absolute path (on the filesystem, not the logical URL) to the current location in such a way that I can pass that to the constructor.

Part of my problem is that my dev box is Windows but I will publish this to a Unix box, so the paths cannot be the same i.e. on Windows C:/.... and on unix /usr/...

© Stack Overflow or respective owner

Related posts about fileoutputstream

Related posts about java