Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Bastet Massri   on Jul 28 In Java Category.

  
Question Answered By: Debbie Reyes   on Jul 28

You can delete  file in java by following method:

1. Create a File Object to your file, example:

File myTempFile = new File("C:/temp/sample.txt");
// Check if it is a file, i.e, no directory and file exist
if( myTempFile.isFile() && myTempFile.exists() ) {
// Then delete file
myTempFile.delete();
}

Dont forget to import java.io.* at the top.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on How do I do to delete files? Or get search suggestion and latest updates.


Tagged: