|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
Utils.java | 100% | 100% | 100% | 100% |
|
1 | /* | |
2 | * Utils.java | |
3 | * | |
4 | * Created on April 10, 2007, 11:32 PM | |
5 | * | |
6 | * JTR is free software; you can redistribute it and/or modify it under the | |
7 | * terms of the GNU General Public License as published by the Free Software | |
8 | * Foundation; either version 2, or (at your option) any later version. | |
9 | */ | |
10 | ||
11 | package jtr.ui.swing; | |
12 | ||
13 | import java.io.File; | |
14 | ||
15 | /** | |
16 | * Utility class for obtaining the extension of a given file. | |
17 | * @author frusso | |
18 | * @version 4.0 | |
19 | * @since 4.0 | |
20 | */ | |
21 | class Utils { | |
22 | ||
23 | public final static String XLS = "xls"; | |
24 | ||
25 | /* | |
26 | * Get the extension of a file. | |
27 | */ | |
28 | 52 | static String getExtension(File f) { |
29 | 52 | String ext = null; |
30 | 52 | String s = f.getName(); |
31 | 52 | int i = s.lastIndexOf('.'); |
32 | ||
33 | 52 | if (i > 0 && i < s.length() - 1) { |
34 | 32 | ext = s.substring(i+1).toLowerCase(); |
35 | } | |
36 | 52 | return ext; |
37 | } | |
38 | } |
|