File syntax for subdirectory

I use creatWriter to output to a file.
it works for the first level dircetory
example: createWriter("c:/main "+string);

so i created a c:/main/reports

but when i try to output to that sub directory it just writes it to the c:/main
example: createWriter("c:/main/reports "+string);

What’s wrong? What is the syntax for file strings sub directory access?
Can i access subdirectories directly with file strings?
Can i go more than 1 directory deep?

( -a- make sure the user has write privileges there )
-b- if

createWriter("c:/main/reports "+string);

creates a file in
the filename might be
reports and my file name in string variable


or can also try a file dialog

You might need to create the folders if they don’t exist. For instance, you can call mkdir from the File class, a class provided by the JRE:


1 Like