You need to create a directory.
mkdirs( ) method.
Of the two methods used for creating directories,
mkdir( ) creates just one directory while
mkdirs( ) creates any parent directories that are needed. For
/home/ian exists and is a directory,
then the calls:
new File("/home/ian/bin").mkdir( ); new File("/home/ian/src").mkdir( );
will succeed, whereas:
new File("/home/ian/once/twice/again").mkdir( );
will fail, assuming that the directory
not exist. If you wish to create a whole path of directories, you
File to make all the directories at
once by using
new File("/home/ian/once/twice/again").mkdirs( );
Both variants of this command return
true if they
false if they fail. Notice that it is
possible (but not likely) for
mkdirs( ) to create
some of the directories and then fail; in this case, the newly
created directories will be left in the filesystem.
Notice the spelling:
mkdir( ) is all lowercase.
While this might be said to violate the normal Java naming
conventions (which would suggest
mkDir( ) as the
name), it is the name of the underlying operating system call and
command on both Unix and DOS (though DOS allows
md as an alias at the command-line level).