Hello all,
small question here.
How can i make a new folder on HD?
Tried
File f1=new File("");
if ( f1.mkDir ( sketchPath("")+"//"+"c1" ) ) {
//
}
or
File f1=new File(sketchPath("")+"//"+"c1");
if (f1.mkDir()) {
//
}
coming from https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/io/File.html#mkdir()
but something is missing…?
Thank you!
Chrisir
Chrisir:
mkDir()
Reference link you’ve posted says it’s mkdir() !
1 Like
Thanks!!!
This seems to work:
File f1=new File(sketchPath("")+"//"+"c1");
if (f1.mkdir()) {
//
}
Processing got more streamlined methods for paths like savePath() , sketchFile() and others:
final String path = savePath("c1/someFile.txt");
println(path);
exit();
final File path = sketchFile("c1");
println(path);
println(path.mkdir());
exit();
2 Likes
svan
April 29, 2023, 3:22am
5
On MacOS first example does nothing. Second example creates an empty folder, not a file.
On Windows both examples create a subfolder “c1/” if it doesn’t exist yet inside sketch’s folder.
mnse
April 29, 2023, 1:46pm
7
Hi,
I would recommend to use java.nio instead of java.io because of several advantages, especially wrt error handling. For creating files and directories,take a look here …
Cheers
— mnse
1 Like