Ejemplo n.º 1
0
 static {
   try {
     if (CrossSystem.isWindows()) {
       supported = com.sun.jna.platform.win32.W32FileUtils.getInstance().hasTrash();
     } else if (CrossSystem.isMac()) {
       supported = com.sun.jna.platform.mac.MacFileUtils.getInstance().hasTrash();
     }
   } catch (final Throwable e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 2
0
 public static void moveToTrash(File... files) throws IOException {
   if (isTrashSupported()) {
     if (CrossSystem.isWindows()) {
       for (File f : files) {
         if (!f.exists()) {
           throw new FileNotFoundException(f.getAbsolutePath());
         }
       }
       com.sun.jna.platform.win32.W32FileUtils.getInstance().moveToTrash(files);
     } else if (CrossSystem.isMac()) {
       for (File f : files) {
         if (!f.exists()) {
           throw new FileNotFoundException(f.getAbsolutePath());
         }
       }
       com.sun.jna.platform.mac.MacFileUtils.getInstance().moveToTrash(files);
     }
   }
 }