import java.io.File;
import java.io.IOException;
import com.sun.jna.platform.FileUtils;
public class MoveToTrash {
public static void main(String[] args){
FileUtils fileUtils = FileUtils.getInstance();
if (fileUtils.hasTrash()) {
try {
fileUtils.moveToTrash( new File[] {new File("c:/temp/dummy.txt") });
}
catch (IOException ioe) {
ioe.printStackTrace();
}
}
else {
System.out.println("No Trash available");
}
}
}
import java.io.*;
File dir;
File[] list;
// filter files to only use jpg and png
FilenameFilter filterPics = new FilenameFilter() {
boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".jpg") || name.toLowerCase().endsWith(".png") || name.toLowerCase().endsWith(".JPG");
}
};
/// SETUP
File dir = new File(dataPath(foldername));
list = dir.listFiles(filterPics);
for (int i = 0; i < list.length; i++) {
// list[i].getAbsolutePath()
}