1 19 20 package org.netbeans.modules.javacore.scanning; 21 22 import java.io.File ; 23 import java.io.FileInputStream ; 24 import java.io.FileNotFoundException ; 25 import java.io.IOException ; 26 import java.io.InputStream ; 27 import org.openide.ErrorManager; 28 29 33 class FileEntry implements FileInfo { 34 private File file; 35 private String path; 36 37 38 public FileEntry(File f,String p) { 39 file=f; 40 path=p; 41 } 42 43 public InputStream getInputStream() throws FileNotFoundException { 44 return new FileInputStream (file); 45 } 46 47 public String getName() { 48 return file.getName(); 49 } 50 51 public boolean isDirectory() { 52 return file.isDirectory(); 53 } 54 55 public long lastModified() { 56 return file.lastModified(); 57 } 58 59 public FileInfo[] listFiles() { 60 if (isDirectory()) { 61 File [] files=file.listFiles(); 62 63 if (files!=null) { 64 int i; 65 FileInfo[] infos=new FileInfo[files.length]; 66 String pathPrefx=path; 67 68 if (path.length()>0) 69 pathPrefx=path.concat("/"); for (i=0;i<infos.length;i++) { 71 File f=files[i]; 72 73 infos[i]=new FileEntry(f,pathPrefx.concat(f.getName())); 74 } 75 return infos; 76 } 77 } 78 return EMPTY_ARR; 79 } 80 81 public String getPath() { 82 return path; 83 } 84 85 public String getCanonicalName() { 86 try { 87 return file.getCanonicalPath(); 88 } catch (IOException ex) { 89 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 90 return getName(); 91 } 92 } 93 } 94 | Popular Tags |