public class Util
extends Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static long |
calcFolderSize(File folder)
Calculate the size of the contents of a folder.
|
static long |
calcSize(File file)
Function to return the length of the file, or entire directory, including
the component files and sub-folders if passed.
|
static boolean |
containsNonASCII(String what) |
static String |
contentsToClassPath(File folder)
Given a folder, return a list of absolute paths to all jar or zip files
inside that folder, separated by pathSeparatorChar.
|
static void |
copyDir(File sourceDir,
File targetDir)
Copy a folder from one place to another.
|
static void |
copyDirNative(File sourceDir,
File targetDir) |
static void |
copyFile(File sourceFile,
File targetFile) |
static int |
countLines(String what)
Get the number of lines in a file by counting the number of newline
characters inside a String (and adding 1).
|
static File |
createTempFolder(String prefix,
String suffix,
File directory)
Create a temporary folder by using the createTempFile() mechanism,
deleting the file it creates, and making a folder using the location
that was provided.
|
static byte[] |
gzipEncode(byte[] what) |
static String[] |
listFiles(File folder,
boolean relative)
Recursively creates a list of all files within the specified folder,
and returns a list of their relative paths.
|
static String[] |
listFiles(File folder,
boolean relative,
String extension) |
static File[] |
listJarFiles(File folder) |
static byte[] |
loadBytesRaw(File file)
Same as PApplet.loadBytes(), however never does gzip decoding.
|
static String |
loadFile(File file)
Grab the contents of a file as a string.
|
static StringList |
packageListFromClassPath(String path)
A classpath, separated by the path separator, will contain
a series of .jar/.zip files or directories containing .class
files, or containing subdirectories that have .class files.
|
static StringDict |
readSettings(File inputFile)
Read from a file with a bunch of attribute/value pairs
that are separated by = and ignore comments with #.
|
static StringDict |
readSettings(String filename,
String[] lines)
Parse a String array that contains attribute/value pairs separated
by = (the equals sign).
|
static boolean |
removeDir(File dir)
Remove all files in a directory and the directory itself.
|
static boolean |
removeDir(File dir,
boolean printErrorMessages)
Remove all files in a directory and the directory itself.
|
static void |
saveFile(String text,
File file)
Spew the contents of a String object out to a file.
|
static void |
unzip(File zipFile,
File dest) |
public static int countLines(String what)
public static byte[] loadBytesRaw(File file) throws IOException
IOException
public static StringDict readSettings(File inputFile)
public static StringDict readSettings(String filename, String[] lines)
public static void copyFile(File sourceFile, File targetFile) throws IOException
IOException
public static String loadFile(File file) throws IOException
IOException
public static void saveFile(String text, File file) throws IOException
IOException
public static File createTempFolder(String prefix, String suffix, File directory) throws IOException
IOException
public static void copyDir(File sourceDir, File targetDir) throws IOException
IOException
public static void copyDirNative(File sourceDir, File targetDir) throws IOException
IOException
public static boolean removeDir(File dir)
public static boolean removeDir(File dir, boolean printErrorMessages)
public static long calcSize(File file)
file
- The file or folder to calculatepublic static long calcFolderSize(File folder)
public static String[] listFiles(File folder, boolean relative)
relative
- true return relative paths instead of absolute pathspublic static String[] listFiles(File folder, boolean relative, String extension)
public static File[] listJarFiles(File folder)
folder
- source folder to searchpublic static String contentsToClassPath(File folder)
public static StringList packageListFromClassPath(String path)
path
- the input classpathpublic static void unzip(File zipFile, File dest)
public static byte[] gzipEncode(byte[] what) throws IOException
IOException
public static final boolean containsNonASCII(String what)