Creating a file in a directory



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

.



Relevant Pages

  • Re: Creating a file in a directory
    ... >where newFile is a File object. ... >in a directory other than the current working directory? ... use an absolute file reference, or a relative on with ../ in it to ...
    (comp.lang.java.help)
  • Re: Creating a file in a directory
    ... where newFile is a File object. ... in a directory other than the current working directory? ... Any clue? ...
    (comp.lang.java.help)