2005/11/17

[Java]刪除檔案

Source File Name : DeleteFile.java
-----------------------------------------------------------
import java.io.*;

class DeleteFile
{
  public static void main(String[] args)
  {
    System.out.println("Delete File : c:\\test.txt");

    File f1 = new File("C:\\test.txt");
    if ( f1.delete() ) {
      System.out.println("Delete Succes!!");
    }
    else {
      System.out.println("Delete Fail!!");
    }
  }
}
-----------------------------------------------------------


Result :
-----------------------------------------------------------
Delete File : c:\test.txt
Delete Succes!!

-----------------------------------------------------------

0 Comments:

張貼留言

<< Home