public class Files extends Object
| Constructor and Description |
|---|
Files() |
| Modifier and Type | Method and Description |
|---|---|
static JSONArray |
listDirectory(String dir)
List files in a directory.
|
static String |
readFileUTF8(String file)
Read a file return the contents as a String assuming the file is UTF-8.
|
static String |
selectDirectory(Component component,
String title)
Show a directory selector dialog.
|
static void |
writeFileUTF8(String file,
String content)
Write a String to a file in UTF-8 encoding.
|
public static String selectDirectory(Component component, String title)
title - The title for the dialog.public static JSONArray listDirectory(String dir) throws JSONException
Example:
[ { d: 0, n: "foo.txt", s: 1024 }, { d: 1, n: "subdir"} ]
Where:title - The title for the dialog.JSONExceptionpublic static String readFileUTF8(String file) throws IOException
file - the file to readIOException - thrown when reading the file throws an IOException and
also when the file is too large to marshal through LiveConnect (currently
128KB, see MAX_FILE_SIZE final)public static void writeFileUTF8(String file, String content) throws IOException
file - the file to writecontent - String to write to the file in UTF-8.IOExceptionCopyright © 2015. All rights reserved.