0,0 → 1,59 |
package src.control; |
|
/** This file contains the ExtensionFilter class. |
* |
* @author S. McSporran |
* |
* @version $Revision: 1.00 |
* |
* Last modification: $Date: 2003/07/11 12:20:03 $ |
* |
*/ |
|
import java.io.File; |
|
/** The ExtensionFilter class provides a method to get the |
* extension of a file |
* |
* @author S. McSporran |
*/ |
|
public class ExtExtractor { |
|
public final static String xml = "xml"; |
public final static String xsd = "xsd"; |
public final static String dtd = "dtd"; |
|
|
/** This method scans a filename and returns it's extension if |
* existent. |
* |
* @author S. McSporran |
* @param f: A representation of a file's name. |
* |
* Last revision: 11-Jul-2003 |
*/ |
public static String getExtension(File f) { |
|
String extension; |
|
/* Get the file's name as String. */ |
String fileName = f.getName(); |
|
/* Get the position of the last dot in the file's name. */ |
int i = fileName.lastIndexOf('.'); |
|
/* If there is any dot other than a beginning dot and if it is not at the end of the file. */ |
if (i > 0 && i < fileName.length() - 1) { |
|
/* Get the rest of the file name after the last dot as lower case characters. */ |
extension = fileName.substring(i+1).toLowerCase(); |
return extension; |
} |
else { |
|
/* Return null if the file does not have an extension. */ |
return null; |
} |
} |
} |
Property changes: |
Added: svn:keywords |
+LastChangedDate LastChangedRevision LastChangedBy HeadURL Id |
\ No newline at end of property |