Enum FileManager
- java.lang.Object
-
- java.lang.Enum<FileManager>
-
- com.google.blocks.ftcrobotcontroller.util.FileManager
-
- All Implemented Interfaces:
Serializable
,Comparable<FileManager>
public enum FileManager extends Enum<FileManager>
A enum that provides utility methods related to managing files in a directory.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
copyFile(String oldName, String newName)
Copies the file with the given name.boolean
deleteFiles(String[] names)
Delete the files with the given names.String
fetchFileContent(String name)
Returns the content of the file with the given name.String
fetchFiles()
Returns the names of existing files.String
fetchJavaScript()
String
getPathForFile(String name)
boolean
isValidName(String name)
Returns true if the given name is not null and contains only valid characters.void
renameFile(String oldName, String newName)
Renames the file with the given name.void
saveFile(String name, String base64Content)
Save a file.static FileManager
valueOf(String name)
Returns the enum constant of this type with the specified name.static FileManager[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
SOUNDS
public static final FileManager SOUNDS
-
MODELS
public static final FileManager MODELS
-
-
Method Detail
-
values
public static FileManager[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (FileManager c : FileManager.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static FileManager valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
fetchJavaScript
public String fetchJavaScript() throws IOException
- Throws:
IOException
-
fetchFiles
public String fetchFiles() throws IOException
Returns the names of existing files.- Throws:
IOException
-
isValidName
public boolean isValidName(String name)
Returns true if the given name is not null and contains only valid characters. This function does not check whether the file with the given name exists.
-
fetchFileContent
public String fetchFileContent(String name) throws IOException
Returns the content of the file with the given name.- Parameters:
name
- the name of the file- Throws:
IOException
-
saveFile
public void saveFile(String name, String base64Content) throws IOException
Save a file.- Parameters:
name
- the name of the file to savebase64Content
- the content to write to the file, encoded with base64.- Throws:
IOException
-
renameFile
public void renameFile(String oldName, String newName) throws IOException
Renames the file with the given name.- Parameters:
oldName
- the old name of the filenewName
- the new name of the file- Throws:
IOException
-
copyFile
public void copyFile(String oldName, String newName) throws IOException
Copies the file with the given name.- Parameters:
oldName
- the old name of the filenewName
- the new name of the file- Throws:
IOException
-
deleteFiles
public boolean deleteFiles(String[] names)
Delete the files with the given names.- Parameters:
names
- the names of the files to delete
-
-