Package open.java.toolkit.files
Class Files
- java.lang.Object
-
- open.java.toolkit.files.Files
-
public class Files extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Files()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancreateDirectory(java.lang.String path)Creates a directory if it doesn't already exists.static booleancreateFile(java.lang.String path)Creates a file if it doesn't already exists.static booleandelete(java.lang.String path)Deletes a file or a directory.static booleandirectoryExists(java.lang.String path)Checks if a directory exists or not.static booleanfileExists(java.lang.String path)Checks if a file exists or not.static byte[]readBytes(java.lang.String path)Reads a file's content, as a byte array.static java.lang.StringreadFile(java.lang.String path)Reads a file's content, as a string.static java.lang.String[]readLines(java.lang.String path)Reads a file's content, as a string array.static voidwriteBytes(java.lang.String path, byte[] content, boolean append)Writes bytes to a file.static voidwriteLines(java.lang.String path, java.lang.String[] content, boolean append)Writes lines to a file.static voidwriteString(java.lang.String path, java.lang.String content, boolean append)Writes a string to a file.
-
-
-
Method Detail
-
readFile
public static java.lang.String readFile(java.lang.String path)
Reads a file's content, as a string.- Parameters:
path- The path of the file to read from.- Returns:
- The file's content, as a string.
-
readLines
public static java.lang.String[] readLines(java.lang.String path)
Reads a file's content, as a string array.- Parameters:
path- The path of the file to read from.- Returns:
- The file's content, as a string array.
-
readBytes
public static byte[] readBytes(java.lang.String path)
Reads a file's content, as a byte array.- Parameters:
path- The path of the file to read from.- Returns:
- The file's content, as a byte array.
-
writeString
public static void writeString(java.lang.String path, java.lang.String content, boolean append)Writes a string to a file.- Parameters:
path- The path of the file to write to.content- The new content.append- Whether or not to append the content to the file.
-
writeLines
public static void writeLines(java.lang.String path, java.lang.String[] content, boolean append)Writes lines to a file.- Parameters:
path- The path of the file to write to.content- The new content.append- Whether or not to append the content to the file.
-
writeBytes
public static void writeBytes(java.lang.String path, byte[] content, boolean append)Writes bytes to a file.- Parameters:
path- The path of the file to write to.content- The new content.append- Whether or not to append the content to the file.
-
fileExists
public static boolean fileExists(java.lang.String path)
Checks if a file exists or not.- Parameters:
path- The path of the file to check from.- Returns:
- Whether or not the file exists.
-
createFile
public static boolean createFile(java.lang.String path)
Creates a file if it doesn't already exists.- Parameters:
path- The path of the file to create.- Returns:
- Whether or not the file has been successfully created.
-
createDirectory
public static boolean createDirectory(java.lang.String path)
Creates a directory if it doesn't already exists.- Parameters:
path- The path of the directory to create.- Returns:
- Whether or not the directory has been successfully created.
-
directoryExists
public static boolean directoryExists(java.lang.String path)
Checks if a directory exists or not.- Parameters:
path- The path of the directory to check from.- Returns:
- Whether or not the directory exists.
-
delete
public static boolean delete(java.lang.String path)
Deletes a file or a directory.- Parameters:
path- The path of the file/directory to delete.- Returns:
- Whether or not the file/directory has been successfully deleted.
-
-