java.lang.Object
org.cybergarage.util.FileUtil

public final class FileUtilextends Object
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 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

      public static final byte[] load(String fileName)
      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

      public static final byte[] load(File file)
      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

      public static final byte[] load(FileInputStream fin)
      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

      public static final boolean isXMLFileName(String name)
      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