-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUtils.java
More file actions
31 lines (27 loc) · 910 Bytes
/
Utils.java
File metadata and controls
31 lines (27 loc) · 910 Bytes
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
import java.io.File;
import javax.swing.ImageIcon;
/* Utils.java is a 1.4 example used by FileChooserDemo2.java. */
public class Utils {
public final static String hs = "hs";
public final static String sum = "sum";
public final static String formula = "for";
public final static String ind = "ind";
public static String getExtension(File f) {
String ext = null;
String s = f.getName();
int i = s.lastIndexOf('.');
if (i > 0 && i < s.length() - 1) {
ext = s.substring(i+1).toLowerCase();
}
return ext;
}
protected static ImageIcon createImageIcon(String path) {
java.net.URL imgURL = Utils.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}
}