Class TextHelper

java.lang.Object
org.odinware.odinrunes.TextHelper

public class TextHelper extends Object
The TextHelper class provides utility methods for working with text files.
  • Constructor Details

    • TextHelper

      public TextHelper(String filePath)
      Constructs a TextHelper object with the specified file path.
      Parameters:
      filePath - the path to the text file
  • Method Details

    • checkAndPopulateFileIfEmpty

      public void checkAndPopulateFileIfEmpty()
      Checks if the file is empty, and populates it with default content if necessary.
    • writeStringToFile

      public void writeStringToFile(String content)
      Writes the specified string content to the file, overwriting its previous content.
      Parameters:
      content - the string content to write
    • appendStringToFile

      public void appendStringToFile(String content)
      Appends the specified string content to the file.
      Parameters:
      content - the string content to append
    • appendOdinFirstInfo

      public void appendOdinFirstInfo(String model, String date)
      Appends the Odin first info to the file.
      Parameters:
      model - the Odin model
      date - the date
    • appendUserInfo

      public void appendUserInfo()
      Appends the user info to the file.
    • appendOverInfoWithError

      public void appendOverInfoWithError()
      Appends the over info with an error to the file.
    • appendAssistantInfo

      public void appendAssistantInfo()
      Appends the assistant info to the file.
    • appendOverInfo

      public void appendOverInfo()
      Appends the over info to the file.
    • openTextFile

      public void openTextFile()
      Opens the text file using the default system program.
    • getMessages

      public org.json.JSONArray getMessages()
      Retrieves the messages from the text file.
      Returns:
      a JSONArray containing the messages
    • isFirstLineValid

      public static boolean isFirstLineValid(File file)
      Checks if the first line of the file contains valid Odin information.
      Parameters:
      file - the file to check
      Returns:
      true if the first line is valid, false otherwise
    • readIntoString

      public static String readIntoString(String filePath)