1 4 package org.oddjob.io; 5 6 import java.io.File ; 7 import java.util.Arrays ; 8 import java.util.HashSet ; 9 import java.util.Set ; 10 11 16 public class Files { 17 18 25 public static File [] expand(File [] files) { 26 Set results = new HashSet (); 27 for (int i = 0; i < files.length; ++i) { 28 results.addAll(Arrays.asList(new WildcardSpec(files[i]).findFiles())); 29 } 30 return (File []) results.toArray(new File [0]); 31 } 32 33 39 public static void verifyReadable(File [] files) 40 throws RuntimeException { 41 for (int i = 0; i < files.length; ++i) { 42 if (!files[i].exists()) { 43 throw new RuntimeException ("File " + files[i] + " does not exist."); 44 } 45 if (!files[i].canRead()) { 46 throw new RuntimeException ("File " + files[i] + " can not be read."); 47 } 48 } 49 } 50 51 57 public static void verifyWrite(File [] files) 58 throws RuntimeException { 59 for (int i = 0; i < files.length; ++i) { 60 if (!files[i].exists()) { 61 throw new RuntimeException ("File " + files[i] + " does not exist."); 62 } 63 if (!files[i].canWrite()) { 64 throw new RuntimeException ("File " + files[i] + " can not be changed."); 65 } 66 } 67 } 68 } 69 | Popular Tags |