Class FileManager


  • public class FileManager
    extends java.lang.Object
    A file manager that provides standard functionalities for communicating with the file system.
    • Constructor Summary

      Constructors 
      Constructor Description
      FileManager​(java.lang.String workdir)
      Builds a new manager that will produce files in the given workdir.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Collection<java.lang.String> createdFiles()
      Yields the collection of file names that have been created by this manager.
      java.io.Writer mkDotFile​(java.lang.String name)
      Creates a UTF-8 encoded file with the given name, appending the dot extension.
      java.io.Writer mkOutputFile​(java.lang.String name)
      Creates a UTF-8 encoded file with the given name.
      java.io.Writer mkOutputFile​(java.lang.String name, boolean bom)
      Creates a UTF-8 encoded file with the given name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileManager

        public FileManager​(java.lang.String workdir)
        Builds a new manager that will produce files in the given workdir.
        Parameters:
        workdir - the path to the directory where files will be created by this manager
    • Method Detail

      • createdFiles

        public java.util.Collection<java.lang.String> createdFiles()
        Yields the collection of file names that have been created by this manager.
        Returns:
        the names of the created files
      • mkOutputFile

        public java.io.Writer mkOutputFile​(java.lang.String name)
                                    throws java.io.IOException
        Creates a UTF-8 encoded file with the given name. If name is a path, all missing directories will be created as well. The given name will be joined with the workdir used to initialize this file manager, thus raising an exception if name is absolute.
        Parameters:
        name - the name of the file to create
        Returns:
        a Writer instance that can write to the created file
        Throws:
        java.io.IOException - if something goes wrong while creating the file
      • mkOutputFile

        public java.io.Writer mkOutputFile​(java.lang.String name,
                                           boolean bom)
                                    throws java.io.IOException
        Creates a UTF-8 encoded file with the given name. If name is a path, all missing directories will be created as well. The given name will be joined with the workdir used to initialize this file manager, thus raising an exception if name is absolute.
        Parameters:
        name - the name of the file to create
        bom - if true, the bom marker  will be written to the file
        Returns:
        a Writer instance that can write to the created file
        Throws:
        java.io.IOException - if something goes wrong while creating the file
      • mkDotFile

        public java.io.Writer mkDotFile​(java.lang.String name)
                                 throws java.io.IOException
        Creates a UTF-8 encoded file with the given name, appending the dot extension. If name is a path, all missing directories will be created as well. The name will be stripped of any characters that might cause problems in the file name. The given name will be joined with the workdir used to initialize this file manager, thus raising an exception if name is absolute.
        Parameters:
        name - the name of the file to create
        Returns:
        a Writer instance that can write to the created file
        Throws:
        java.io.IOException - if something goes wrong while creating the file