A PrintWriter
created this way will expect a path, which can be either relative or absolute.
Relative paths are relative to the working directory.
Absolute paths on the other hand need to contain the full path from the root directory (or directories, as it happens), so on a Windows box it'll be something like c:/foo/bar.txt
, on Unix-type systems /home/nobody/foo/bar.txt
.
The exact rules on absolute and relative paths can be found here.
A note though on the use of relative paths. Be careful when you're relying on them because you have no way of knowing what your working directory is going to be: when you run your application from Eclipse, it will default to your project directory but if you package it up and run from command line, it will be somewhere else.
And even if you're only running it from Eclipse, writing in your project folder isn't the best of ideas. Not only is it possible to accidentally overwrite your source code, but your code won't be very portable, if later on you decide to package everything up in a jar file, you'll find you won't be able to find those directories any more (because they're all packaged up).