Class FileUtility


  • public final class FileUtility
    extends java.lang.Object
    A set of utility classes for reading files
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  FileUtility.LogOutputFileType
      An enum containing the different types of input files that we can handle.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Optional<FileUtility.LogOutputFileType> getOptionalLogOutputType​(org.openstreetmap.atlas.streaming.resource.File logFile)
      Determine whether or not this file is something we can handle, and classify it accordingly.
      static java.io.BufferedReader getReader​(org.openstreetmap.atlas.streaming.resource.File inputFile, FileUtility.LogOutputFileType fileType)
      Read a file that we know we should be able to handle
      • Methods inherited from class java.lang.Object

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

      • getOptionalLogOutputType

        public static java.util.Optional<FileUtility.LogOutputFileType> getOptionalLogOutputType​(org.openstreetmap.atlas.streaming.resource.File logFile)
        Determine whether or not this file is something we can handle, and classify it accordingly.
        Parameters:
        logFile - any file
        Returns:
        if this file is something this command can handle, the appropriate LogOutputFileType enum value; otherwise, an empty optional.
      • getReader

        public static java.io.BufferedReader getReader​(org.openstreetmap.atlas.streaming.resource.File inputFile,
                                                       FileUtility.LogOutputFileType fileType)
                                                throws java.io.IOException
        Read a file that we know we should be able to handle
        Parameters:
        inputFile - Some file with a valid, appropriate extension.
        fileType - The type of file that inputFile is
        Returns:
        a BufferedReader to read inputFile
        Throws:
        java.io.IOException - if the file is not found or is poorly formatted, given its extension. For example, if this file is gzipped and something goes wrong in the unzipping process, it might throw an error