Solved

How to create directory???

Posted on 2003-11-18
3
202 Views
Last Modified: 2010-04-01
hello,

i am having problem on how to create directory in my server.
the situation is some kind like this...
first of all the system willl goes to the path i'm given..lets say.... /var/www/html
then..it will check whether the name i'm given eg:John...is existed or not..
if not existed then it will create the directory name or else will give some alert...
and last, after that one index file will create in the directory...

can anybody tell me how to do it step by step with the sample code...i dunno how to make start...

thanx in advance
0
Comment
Question by:eg4
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
jimmack earned 125 total points
Comment Utility
try
{
    File dir = new File("/var/www/html/John");

    if (dir.exists())
    {
        if (dir.isDirectory())
        {
             // Create your index file here
        }
        else
        {
            System.out.println(dir + " exists, but is a file, not a directory");
        }
    }
    else
    {
        if (dir.mkdirs())
        {
            System.out.println("Directory " + dir + " successfully created");
        }
        else
        {
            System.out.println("Failed to created directory " + dir);
        }
    }
}
catch (IOException ioe)
{
    System.out.println("IOException: " + ioe.toString());
}
0
 

Author Comment

by:eg4
Comment Utility
thanx jimmack. it works perfect like i want!!!!
thanx a bunch....!!
0
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
No problem ;-)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now