[Code Application]javase Program recursive delete. bak file under folder source code

Source: Internet
Author: User

This address: http://blog.csdn.net/sushengmiyan/article/details/39158939

This article Sushengmiyan

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

Now it is customary to write JS code using EditPlus to write code, but each time it is automatically generated editplus a temporary file. bak, looking at all the uncomfortable, so simply write a delete program, when using EditPlus edit the completion of the code, double-click the jar file is much more convenient.

A simple program that contains a few small processes for packaging a release jar file:

1. New Project Deletebakfiles

2. Create a project package Com.susheng.deletebakfiles

3. Package the new class Maindelete type code

The code is as follows:

Package Com.susheng.deletebakfiles;import Java.io.file;//import Javax.swing.joptionpane;import Javax.swing.joptionpane;import Com.susheng.deletebakfiles.util.getcurpath;public class MainDelete {// Recursively deletes all files under the specified path public static void Deletebak (file file) {  if (File.isfile ()) {if (File.getabsolutepath ())  . EndsWith (". bak"))  {//joptionpane.showmessagedialog (null, File.getabsolutepath (), "Current Path", Joptionpane.information_message);        File.delete ();  }  }  else  {     file[] files = file.listfiles ();     for (file f:files)     {        deletebak (f);//recursive deletion of each file     }   }}public static void Main (string[] args) { Getcurpath path = new Getcurpath (); String FilePath = Path.getcurpath (); File File = new file (filePath);d eletebak (file); Joptionpane.showmessagedialog (null, "Delete succeeded", "current Path", Joptionpane.information_message);}}

4. New package Com.susheng.deletebakfiles.util New class Getcurpath

Type the code

Package Com.susheng.deletebakfiles.util;import Javax.swing.joptionpane;public class Getcurpath {public    String Getcurpath ()    {          joptionpane.showmessagedialog (null, System.getproperty ("User.dir"), "Current Path", Joptionpane.information_message);  System.out.println (System.getproperty ("User.dir"));  Return System.getproperty ("User.dir");}    }
5. Package into a JAR package release:

Select Eclispe---Export--java--jar then always next select Output Directory Ok


The project code and the jar package are downloaded here:

http://download.csdn.net/detail/sushengmiyan/7885807

Using the method, place the jar file under the bin under the folder you want to delete, double-click to run

Pop-up box to prompt the current path:


Delete again, wait for delete to complete







[Code Application]javase Program recursive delete. bak file under folder source code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.