ดังตัวอย่าง :
package demo.file; import java.io.File; public class DeleteFileExample { /** * @param args */ public static void main(String[] args) { try { File file = new File("C:\\users\\nopphanan7\\newfile.txt"); if (file.delete()) { System.out.println(file.getName() + " is deleted!"); } else { System.out.println("Delete operation is failed."); } } catch (Exception e) { e.printStackTrace(); } } }ผลลัพธ์ที่ได้คือ
newfile.txt is deleted!
0 comments:
Post a Comment