Solved

How to create directory???

Posted on 2003-11-18
3
206 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
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

This tutorial shows how to create a greeting card by combining two image layers and a text layer on a PC using a free image editing app.
An article on effective troubleshooting
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

777 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