1 18 package se.mog.io; 19 20 import java.io.IOException ; 21 import java.net.URI ; 22 23 29 public class File extends java.io.File { 30 private static FileSystem fs = FileSystem.getFileSystem(); 31 32 35 public File(String pathname) { 36 super(pathname); 37 } 38 public File(java.io.File file) { 39 super(file.getPath()); 40 } 41 45 public File(String parent, String child) { 46 super(parent, child); 47 } 48 49 53 public File(java.io.File parent, String child) { 54 super(parent, child); 55 } 56 57 60 public File(URI uri) { 61 super(uri); 62 } 63 68 public static File[] listMounts() throws IOException { 69 return fs.listMounts(); 70 } 71 72 public long getDiskSpaceAvailable() { 73 return fs.getDiskFreeSpace(this).freeBytes; 74 } 75 76 public long getDiskSpaceCapacity() { 77 return fs.getDiskFreeSpace(this).totalBytes; 78 } 79 80 public boolean isSymbolicLink() throws IOException { 81 return !getCanonicalPath().equals(getAbsolutePath()); 82 } 83 87 public boolean deleteRecursive() { 88 if(isDirectory()) { 89 java.io.File files[] = listFiles(); 90 for (int i = 0; i < files.length; i++) { 91 File file = new File(files[i]); 92 file.deleteRecursive(); 93 } 94 } 95 return super.delete(); 96 } 97 98 } 99 | Popular Tags |