日期:2014-05-20 浏览次数:20871 次
public static void main(String[] args) throws IOException { File dir = new File("c/exam/haha"); if (dir.exists() && dir.isDirectory()) { System.out.println("The directory already exits!".toUpperCase()); } else { if (dir.mkdirs()) { System.out.println("the directory has been created!".toUpperCase()); File f = new File(dir, "test.txt"); f.createNewFile(); f.setReadOnly(); System.out.println("end of creation".toUpperCase()); } else { System.out.println("failed!".toUpperCase()); } } }