java.lang.Object
org.cybergarage.util.FileUtil
Utility class for file operations and XML file detection. This class provides static methods for loading file contents into byte arrays and checking if files have XML extensions.
Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionstatic final booleanisXMLFileName(String name) Checks if a filename has an XML extension.static final byte[]Loads the entire contents of a File object into a byte array.static final byte[]load(FileInputStream fin) Loads the entire contents of a FileInputStream into a byte array.static final byte[]Loads the entire contents of a file into a byte array.
Constructor Details
FileUtil
public FileUtil()Constructor. The loaders and the extension test below are static functions of their file arguments, so an instance carries no state.
Method Details
load
Loads the entire contents of a file into a byte array.- Parameters:
fileName- the path to the file to load- Returns:
- the file contents as a byte array, or empty array if an error occurs
load
Loads the entire contents of a File object into a byte array.- Parameters:
file- the File object to load- Returns:
- the file contents as a byte array, or empty array if an error occurs
load
Loads the entire contents of a FileInputStream into a byte array.- Parameters:
fin- the FileInputStream to read from- Returns:
- the stream contents as a byte array, or empty array if an error occurs
isXMLFileName
Checks if a filename has an XML extension.- Parameters:
name- the filename to check- Returns:
- true if the filename ends with ".xml" (case-insensitive), false otherwise