Klasse UtilFiles

java.lang.Object
de.zocher_regel.util.UtilFiles

public final class UtilFiles extends Object
Static routines for file processing.
  • Felddetails

    • BOM

      public static final int BOM
      Byte order mark. printWriter.write(BOM)
      Siehe auch:
    • saveFilter

      static final FilenameFilter saveFilter
      A filename filter that matches files like "..._original"
  • Methodendetails

    • exists

      public static boolean exists(File file)
      Check the existence of a file and log if it is missing
      Parameter:
      file - to be checked
      Gibt zurück:
      if the file exists
    • deleteDuplicates

      public static void deleteDuplicates(ListIterator listIter)
      Delete multiple occurrences from a List.
      Parameter:
      listIter - for iteration, must be able to delete a list element
    • changeExt

      public static File changeExt(File file, String newExt)
      Change the extension of a file.
      Parameter:
      file - with (optional) extension
      newExt - new extension string, starting "*\." is ignored
      Gibt zurück:
      file with new extension
    • changeExt

      public static String changeExt(String fileName, String newExt)
      Change the extension of a file.
      Parameter:
      fileName - with (optional) extension
      newExt - new extension string, starting "*\." is ignored
      Gibt zurück:
      file with new extension
    • cleanUp

      public static void cleanUp(File directory, FilenameFilter filenameFilter)
      Delete backups recursively.
      Parameter:
      directory - in which the backup files are to be deleted.
      filenameFilter - e.g. saveFilter
    • createIfNecessary

      public static void createIfNecessary(File file) throws UtilException
      Create the file if it does not exist.
      Parameter:
      file - which may not exist
      Löst aus:
      UtilException - if the file could not be created
    • determineCharset

      public static Charset determineCharset(File file) throws IOException
      Try to determine the charset by inspecting the BOM.
      Parameter:
      file - whose starting characters are read
      Gibt zurück:
      the Charset (default is ISO_8859_1)
      Löst aus:
      IOException - when the file could not be read
    • edit

      public static void edit(String absolutePath) throws UtilException
      Call the external editor.
      Parameter:
      absolutePath - of the file to be edited
      Löst aus:
      UtilException - in case of any error.
    • edit

      public static void edit(String absolutePath, String title) throws UtilException
      Call the external editor.
      Parameter:
      absolutePath - of the file to be edited
      title - in editor panel, not supported by all editors
      Löst aus:
      UtilException - if the runtime could not excecute the editor
    • list

      public static void list(File file)
      List the file in the logging pane. Its charset is determined automatically.
      Parameter:
      file - to be listed
    • overreadBOM

      public static String overreadBOM(String line)
      A file may beginn with Byte Order Marker FEFF.
      Parameter:
      line - , null is allowed
      Gibt zurück:
      line without BOM
    • saveWithTimestamp

      public static Path saveWithTimestamp(Path path) throws IOException
      Save the file as a backup copy with an suffix.
      Parameter:
      path - of the file to be saved
      Gibt zurück:
      path of the saved file
      Löst aus:
      IOException - if the file could not be saved.
    • stripExtension

      public static String stripExtension(String fileName)
      Strip the extension from filename
      Parameter:
      fileName - (e.g. "xyz.abc")
      Gibt zurück:
      fileName without extension ("abc")