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