Solved

How to create directory???

Posted on 2003-11-18
3
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
jimmack earned 125 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Here's how to start interacting with our community through Post.
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

734 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