DBA Data[Home] [Help]

JAVA SOURCE: SYS.PreupCreateDir

Source


1 import java.lang.*;
2           import java.util.*;
3           import java.io.*;
4 
5           public class PreupCreateDir
6           {
7             public static int create (String path)
8             {
9               path = path.substring(1,path.length()-1); /* Take off leading/trailing quotes */
10               File myFile = new File(path);
11               if (myFile.exists())
12               {
13                 if (myFile.canWrite())
14                   return 1;  /* Directory exists and is writable, OK */
15                 else
16                   return 2;  /* Directory exists and is not writable, NOT OK */
17               }
18               else
19               {
20                 if (myFile.mkdirs())
21                   return 1;  /* Directory created, OK */
22                 else
23                   return 4;  /* Directory could not be created, NOT OK */
24               }
25             }
26           }