Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to create directory???

Posted on 2003-11-18
3
Medium Priority
?
214 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 500 total points
ID: 9770013
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
ID: 9775899
thanx jimmack. it works perfect like i want!!!!
thanx a bunch....!!
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9777295
No problem ;-)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Do online retailers and e-commerce sites even need to bother with the season? Is it lucrative to update and prepare your site for Black Friday and Cyber Monday shoppers? We'll find out now.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Loops Section Overview
Suggested Courses

824 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