Solved

How to create directory???

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Getting to know the threat landscape in which DDoS has evolved, and making the right choice to get ourselves geared up to defend against  DDoS attacks effectively. Get the necessary preparation works done and focus on Doing the First Things Right.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

623 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