I'm able to create a new file using
OutputStream savedFile = new FileOutputStream( newFile );
where newFile is a File object. However, how do I create this new file
in a directory other than the current working directory? For example
assume there is a directory in the current working directory 'test' and
I want to create a file in 'test/blah.txt'
I tried something like this:
File newFile = new File( "test/blah.txt" );
OutputStream savedFile = new FileOutputStream( newFile );
But Linux (FC2) keeps saying that "test/blah.txt" is a directory, not a
file. Any clue?
-Kevin
Mark Thomas - 31 Dec 2005 18:52 GMT
> I'm able to create a new file using
>
[quoted text clipped - 8 lines]
>
> File newFile = new File( "test/blah.txt" );
add:
newFile.createNewFile();
in here.
> OutputStream savedFile = new FileOutputStream( newFile );
>
> But Linux (FC2) keeps saying that "test/blah.txt" is a directory, not a
> file. Any clue?
>
> -Kevin
Mark
Roedy Green - 03 Jan 2006 00:48 GMT
On 30 Dec 2005 13:13:01 -0800, "kevinhu19@gmail.com"
<kevinhu19@gmail.com> wrote, quoted or indirectly quoted someone who
said :
>where newFile is a File object. However, how do I create this new file
>in a directory other than the current working directory?
use an absolute file reference, or a relative on with ../ in it to
navigate to some other directory.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.