1 3 27 28 30 package de.qfs.apps.qflog.logview; 31 32 34 import java.io.File ; 35 import javax.swing.filechooser.FileFilter ; 36 37 39 45 public class LogFileFilter 46 extends FileFilter 47 { 48 50 53 private String desc; 54 55 58 private String [] ext; 59 60 62 64 70 public LogFileFilter (String desc, String ext) 71 { 72 this.ext = new String [] {ext}; 73 this.desc = desc; 74 } 75 76 82 public LogFileFilter (String desc, String [] multi) 83 { 84 this.ext = multi; 85 this.desc = desc; 86 } 87 88 90 92 100 public boolean accept(File file) 101 { 102 if (file.isDirectory()) { 103 return true; 104 } 105 for (int i = 0; i < ext.length; i++) { 106 if (file.getName().endsWith(ext[i])) { 107 return true; 108 } 109 } 110 return false; 111 } 112 113 116 121 public String getDescription() 122 { 123 return desc; 124 } 125 126 129 136 public File forceExtension(File file) 137 { 138 if (file.getName().endsWith(ext[0])) { 139 return file; 140 } 141 return new File (file.getPath() + ext[0]); 142 } 143 144 } 146 | Popular Tags |