Class FileManagement

java.lang.Object
com.github.rhys_h_walker.FileManagement

public class FileManagement extends Object
A static class which implements most of the IO features required by OnRailsLogger
  • Method Details

    • locateFile

      public static File locateFile(LocalDateTime ts, File applicationDirectory)
      Based on a timestamp either locate or create a file for logging
      Parameters:
      ts - The timestamp String to use, format of (YYYY-MM-DD-HH:MM:SS)
      applicationDirectory - A File object which points to the current applications logging directory
      Returns:
      The File object, null on any errors
    • writeToLogFile

      public static void writeToLogFile(String timestamp, LoggingType logType, String message, PrintWriter pw)
      Write a log message to a given file.
      Parameters:
      timestamp - The timestamp String to use, format of (YYYY-MM-DD-HH:MM:SS)
      logType - The type of log that is being output
      message - The logging message that is being output
      pw - Printwriter which is pointed to the file to write, this is cycled in log factory
    • readLogFile

      public static ArrayList<String> readLogFile(File logFile)
      Read in a log file and return it split by line
      Parameters:
      logFile - The File to be read from
      Returns:
      An ArrayList of Strings (Each string is a line), null if error