package com.java.myapp; import java.io.File; public class MyClass { public static void main(String[] args) { String source = "C:\\java\\"; try{ File file = new File(source + "\\mydir"); if (!file.exists()) { if (file.mkdir()) { System.out.println("Directory is created!"); } else { System.out.println("Failed to create directory!"); } } }catch(Exception e){ e.printStackTrace(); } } }
package com.java.myapp; import java.io.File; public class MyClass { public static void main(String[] args) { String source = "C:\\java\\"; try{ File file = new File(source + "\\mydir"); if (file.exists()) { if (file.delete()) { System.out.println("Directory is deleted!"); } else { System.out.println("Failed to delete directory!"); } } }catch(Exception e){ e.printStackTrace(); } } }
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท