File syntax for subdirectory


#1

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?
Thks


#2

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

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

creates a file in
c:/main
the filename might be
reports and my file name in string variable
try

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

or can also try a file dialog
https://processing.org/reference/selectFolder_.html


#3

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: https://docs.oracle.com/javase/7/docs/api/java/io/File.html

Kf