Package org.odinware.odinrunes
Class TextHelper
java.lang.Object
org.odinware.odinrunes.TextHelper
The TextHelper class provides utility methods for working with text files.
-
Constructor Summary
ConstructorDescriptionTextHelper
(String filePath) Constructs a TextHelper object with the specified file path. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Appends the assistant info to the file.void
appendOdinFirstInfo
(String model, String date) Appends the Odin first info to the file.void
Appends the over info to the file.void
Appends the over info with an error to the file.void
appendStringToFile
(String content) Appends the specified string content to the file.void
Appends the user info to the file.void
Checks if the file is empty, and populates it with default content if necessary.org.json.JSONArray
Retrieves the messages from the text file.static boolean
isFirstLineValid
(File file) Checks if the first line of the file contains valid Odin information.void
Opens the text file using the default system program.static String
readIntoString
(String filePath) void
writeStringToFile
(String content) Writes the specified string content to the file, overwriting its previous content.
-
Constructor Details
-
TextHelper
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
Writes the specified string content to the file, overwriting its previous content.- Parameters:
content
- the string content to write
-
appendStringToFile
Appends the specified string content to the file.- Parameters:
content
- the string content to append
-
appendOdinFirstInfo
Appends the Odin first info to the file.- Parameters:
model
- the Odin modeldate
- 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
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
-