TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Creating Directory In Java
Alagunila Meganathan
Aug 10
2016
Code
582
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
CreateDirectory.rar
import
java.io.*;
class
CreateDirectory
{
public
static
void
main(String args[])
{
try
{
String strDirectoy =
"test"
;
String strManyDirectories=
"dir1/dir2/dir3"
;
// Create one directory
boolean
success = (
new
File(strDirectoy)).mkdir();
if
(success) {
System.out.println(
"Directory: "
+ strDirectoy +
" created"
);
}
// Create multiple directories
success = (
new
File(strManyDirectories)).mkdirs();
if
(success) {
System.out.println(
"Directories: "
+ strManyDirectories +
" created"
);
}
}
catch
(Exception e){
//Catch exception if any
System.err.println(
"Error: "
+ e.getMessage());
}
}
}
java
directory