public class Files extends Object
| Constructor and Description |
|---|
Files() |
| Modifier and Type | Method and Description |
|---|---|
static StringBuilder |
loadText(File file)
Returns the text from the specified file as an object of
StringBuilder. |
static StringBuilder |
loadTextFile()
Returns the text from a file as an object of
StringBuilder, the file being selected by a
file chooser dialog. |
static void |
save(String fileName,
CharSequence text)
Saves the specified text to a file.
|
static void |
save(String fileName,
CharSequence text,
boolean showDialog)
Saves the specified text to a file.
|
public static void save(String fileName, CharSequence text)
character sequence.
The file name specifies the name of the file, notably without the
directory.
The directory is given by the directory last visited by
the user by a method of this class, or its home directory by default.
This methods asks the user via a file chooser dialog where the file has to
be saved.fileName - the file name the file is to be saved to.text - the text to be savedsave(java.lang.String, java.lang.CharSequence, boolean)public static void save(String fileName, CharSequence text, boolean showDialog)
character sequence.
The file name specifies the name of the file, notably without the
directory.
The directory is given by the directory last visited by
the user by a method of this class, or its home directory by default.
If a file chooser dialog is to be shown to input the file from the user,
the flag showDialog must be set to true.fileName - the file name the file is to be saved to.text - the text to be savedshowDialog - flag whether a FileChooser dialog is to be shownpublic static StringBuilder loadTextFile()
StringBuilder, the file being selected by a
file chooser dialog.public static StringBuilder loadText(File file) throws FileNotFoundException
StringBuilder.file - File to be loadedFileNotFoundException - if the specified file is not found