1 6 7 package com.quikj.application.utilities.postinstall; 8 9 import java.io.*; 10 import java.util.*; 11 12 16 public class FileUtils 17 { 18 19 public FileUtils() 20 { 21 } 22 23 public static void copy(String src, String dest) 24 throws FileNotFoundException, IOException 25 { 26 FileInputStream fis = new FileInputStream(src); 27 FileOutputStream fos = new FileOutputStream(dest); 28 byte[] buffer = new byte[1000]; 29 30 int size; 31 while ((size = fis.read(buffer)) > 0) 32 { 33 fos.write(buffer, 0, size); 34 } 35 fos.close(); 36 fis.close(); 37 } 38 39 public static void list(File first, 40 File base, 41 String [] suffixes, 42 String [] excludes, 43 ArrayList list) 44 throws FileNotFoundException, IOException 45 { 46 File[] listing = base.listFiles(); 47 for (int i = 0; i < listing.length; i++) 48 { 49 if ((listing[i].getName().equals(".") == true) || 50 (listing[i].getName().equals("..") == true)) 51 { 52 continue; 53 } 54 55 if (listing[i].isDirectory() == true) 56 { 57 boolean l = false; 58 59 if (excludes == null) 60 { 61 l = true; 62 } 63 else 64 { 65 int j; 66 for (j = 0; j < excludes.length; j++) 67 { 68 File dir = new File (first, excludes[j]); 69 if (listing[i].getAbsolutePath().equals(dir.getAbsolutePath()) 72 == true) 73 { 74 l = false; 76 break; 77 } 78 } 79 80 if (j == excludes.length) { 82 l = true; 83 } 84 } 85 86 if (l == true) 87 { 88 list(first, listing[i], suffixes, excludes, list); 89 } 90 continue; 91 } 92 93 boolean l = false; 95 if (suffixes == null) 96 { 97 l = true; 98 } 99 else 100 { 101 for (int j = 0; j < suffixes.length; j++) 102 { 103 if (listing[i].getName().endsWith(suffixes[j]) == true) 104 { 105 l = true; 106 break; 107 } 108 } 109 } 110 111 112 if (l == true) 113 { 114 list.add(listing[i].getAbsolutePath()); 115 } 116 } 117 } 118 119 } 120 | Popular Tags |