|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbe.hogent.tarsos.util.FileUtils
public final class FileUtils
Exports a DatabaseResult to a CSV-file.
Nested Class Summary | |
---|---|
static interface |
FileUtils.RowFilter
|
Field Summary | |
---|---|
static FileUtils.RowFilter |
ACCEPT_ALL_ROWFILTER
|
Method Summary | |
---|---|
static void |
appendFile(java.lang.String contents,
java.lang.String name)
Appends a string to a file on disk. |
static java.lang.String |
basename(java.lang.String fileName)
Returns the filename without path and without extension. |
static java.lang.String |
combine(java.lang.String... path)
Joins path elements using the systems path separator. |
static void |
copyFileFromJar(java.lang.String source,
java.lang.String target)
Copy a file from a jar. |
static void |
cp(java.lang.String source,
java.lang.String target)
Copy from source to target. |
static boolean |
exists(java.lang.String fileName)
Checks if a file exists. |
static void |
export(java.lang.String filename,
java.lang.String[] header,
java.util.List<java.lang.Object[]> data)
|
static java.lang.String |
extension(java.lang.String fileName)
Return the extension of a file. |
static java.lang.String |
getMD5Checksum(java.lang.String filename)
Calculate an MD5 checksum of the first 256kB of a file. |
static java.util.List<java.lang.String> |
glob(java.lang.String directory,
java.lang.String pattern,
boolean recursive)
Return a list of files in directory that satisfy pattern. |
static boolean |
isAudioFile(java.io.File file)
Checks if the name of the file (extension) is a known audio extension. |
static boolean |
isDirectory(java.lang.String inputFile)
Tests whether the file denoted by this abstract pathname is a directory. |
static boolean |
mkdirs(java.lang.String path)
Creates a directory and parent directories if needed. |
static java.util.List<Annotation> |
parseTartiniPitchFile(java.lang.String fileName)
Parses files that can be exported from The Tartini program. |
static java.lang.String |
path(java.lang.String fileName)
Returns the path for a file. path("/home/user/test.jpg") == "/home/user" Uses the correct pathSeparator depending on the operating system. |
static java.util.List<java.lang.String> |
readColumnFromCSVData(java.util.List<java.lang.String[]> data,
int columnIndex,
FileUtils.RowFilter filter)
|
static java.util.List<java.lang.String[]> |
readCSVFile(java.lang.String fileName,
java.lang.String separator,
int expectedColumns)
Reads a CSV-file from disk. |
static java.lang.String |
readFile(java.lang.String name)
Reads the contents of a file. |
static java.lang.String |
readFileFromJar(java.lang.String path)
Reads the contents of a file in a jar. |
static java.util.List<Annotation> |
readPitchAnnotations(java.lang.String fileName)
|
static boolean |
rm(java.lang.String fileName)
Removes a file from disk. |
static java.lang.String |
runtimeDirectory()
|
static java.lang.String |
temporaryDirectory()
|
static void |
writeFile(java.lang.String contents,
java.lang.String name)
|
static void |
writePitchAnnotations(java.lang.String fileName,
java.util.List<Annotation> samples)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final FileUtils.RowFilter ACCEPT_ALL_ROWFILTER
Method Detail |
---|
public static java.util.List<Annotation> parseTartiniPitchFile(java.lang.String fileName)
Time(secs) Pitch(semi-tones) Volume(rms) 0 0 -150 0.301859 72.3137 -108.931 0.325079 72.0692 -79.6062 0.348299 71.9804 -64.634 0.371519 71.9619 -59.5387 0.394739 71.9699 -59.0133 0.417959 71.9717 -59.567 0.441179 71.9854 -59.7326 0.464399 72.011 -58.6959
fileName
- The Tartini pitch file.
public static void writePitchAnnotations(java.lang.String fileName, java.util.List<Annotation> samples)
public static java.util.List<Annotation> readPitchAnnotations(java.lang.String fileName)
public static java.lang.String temporaryDirectory()
public static java.lang.String combine(java.lang.String... path)
path
- The path parts part.
public static java.lang.String getMD5Checksum(java.lang.String filename)
head -c 262144 file_to_calculate_md5_for | md5sum
filename
- The absolute file name of a file used to calculate an md5 checksum of the first 256kB off.
public static java.lang.String runtimeDirectory()
public static void writeFile(java.lang.String contents, java.lang.String name)
contents
- name
- public static void appendFile(java.lang.String contents, java.lang.String name)
contents
- The contents of the file.name
- The name of the file to create.public static java.lang.String readFile(java.lang.String name)
name
- the name of the file to read
public static java.lang.String readFileFromJar(java.lang.String path)
path
- the path to read e.g. /package/name/here/help.html
public static void copyFileFromJar(java.lang.String source, java.lang.String target)
source
- The path to read e.g. /package/name/here/help.htmltarget
- The target to save the file to.public static java.util.List<java.lang.String[]> readCSVFile(java.lang.String fileName, java.lang.String separator, int expectedColumns)
fileName
- the filename, an exception if thrown if the file does not
existseparator
- the separator, e.g. ";" or ","expectedColumns
- The expected number of columns, user -1 if the number is
unknown. An exception is thrown if there is a row with an
unexpected row length.
public static java.util.List<java.lang.String> readColumnFromCSVData(java.util.List<java.lang.String[]> data, int columnIndex, FileUtils.RowFilter filter)
public static void export(java.lang.String filename, java.lang.String[] header, java.util.List<java.lang.Object[]> data)
public static java.util.List<java.lang.String> glob(java.lang.String directory, java.lang.String pattern, boolean recursive)
Return a list of files in directory that satisfy pattern. Pattern should
be a valid regular expression not a 'unix glob pattern' so in stead of
*.wav
you could use .*\.wav
E.g. in a directory home
with the files
test.txt
, blaat.wav
and foobar.wav
the pattern .*\.wav
matches blaat.wav
and
foobar.wav
directory
- A readable directory.pattern
- A valid regular expression.recursive
- A boolean defining if directories should be traversed
recursively.
java.lang.Error
- an error is thrown if the directory is not ... a
directory.
java.util.regex.PatternSyntaxException
- Unchecked exception thrown to indicate a syntax error in a
regular-expression pattern.public static java.lang.String extension(java.lang.String fileName)
fileName
- the file to get the extension for
public static java.lang.String basename(java.lang.String fileName)
fileName
-
public static java.lang.String path(java.lang.String fileName)
path("/home/user/test.jpg") == "/home/user"
fileName
- the name of the file using correct path separators.
public static boolean exists(java.lang.String fileName)
fileName
- the name of the file to check.
public static boolean mkdirs(java.lang.String path)
path
- the path of the directory to create
public static void cp(java.lang.String source, java.lang.String target)
source
- the source file.target
- the target file.public static boolean rm(java.lang.String fileName)
fileName
- the file to remove
public static boolean isDirectory(java.lang.String inputFile)
inputFile
- A pathname string.
public static boolean isAudioFile(java.io.File file)
file
- The file to check.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |