[セットトップ]Javaはフォルダが存在するかどうかを判断し、フォルダを作成する


1、ファイルが存在するかどうかを判断し、作成ファイルが存在しない
    File file=new File("C:\\Users\\QPING\\Desktop\\JavaScript\\2.htm");  
    if(!file.exists())  
    {  
        try {  
            file.createNewFile();  
        } catch (IOException e) {  
            // TODO Auto-generated catch block  
            e.printStackTrace();  
        }  
    }  

2、フォルダが存在するかどうかを判断し、作成フォルダが存在しない
File file =new File("C:\\Users\\QPING\\Desktop\\JavaScript");  
//             
if  (!file .exists()  && !file .isDirectory())    
{     
    System.out.println("//   ");
    file .mkdir();  
} else 
{
    System.out.println("//    ");
}