-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathSimpleFileFilter.java
More file actions
52 lines (43 loc) · 1.09 KB
/
SimpleFileFilter.java
File metadata and controls
52 lines (43 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.io.File;
import javax.swing.filechooser.*;
public class SimpleFileFilter extends FileFilter
{
private String extension = "";
private String description = "";
public SimpleFileFilter()
{
}
public SimpleFileFilter(String extension, String description)
{
if (extension != null)
{
this.extension = extension;
}
if (description != null)
{
this.description = description;
}
}
public boolean accept(File file)
{
if (file != null)
{
if (file.isDirectory())
{
return false;
}
String fileName = file.getName();
int i = fileName.lastIndexOf('.');
if (i > 0 && i < fileName.length() - 1)
{
String end = fileName.substring(i, fileName.length());
return end.equals(extension);
}
}
return false;
}
public String getDescription()
{
return description;
}
}