|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.dfki.lt.tools.tokenizer.FileTools
FileTools
provides static methods to work on files and
stream.
Method Summary | |
static void |
copyFile(java.io.File source,
java.io.File target)
This simply copies a source file to a target file. |
static java.util.List |
getFilesFromDir(java.lang.String aDirectory,
java.lang.String aSuffix)
This recursivly collects all filenames in the directory aDirectory with suffix aSuffix and
returns them in a List . |
static java.nio.ByteBuffer |
readFile(java.io.File aFile)
New NIO based method to read the contents of a file as byte[] array. |
static java.lang.String |
readFileAsString(java.io.File aFile,
java.lang.String aCharSet)
New NIO based method to read a file as a String with the given charset encoding. |
static java.lang.String |
readInputStream(java.io.InputStream is)
Read some input stream and return its content as a string. |
static void |
readInputStream(java.io.OutputStream os,
java.io.InputStream is)
Reads some input stream and writes it into an output stream. |
static byte[] |
readInputStreamToByteArray(java.io.InputStream is)
Read some input stream and return its content as byte array. |
static byte[] |
readUrlToByteArray(java.net.URL url)
Read a url content to a byte array. |
static java.lang.String |
readUrlToString(java.net.URL url)
Read a url content to a string. |
static void |
saveStream(java.io.InputStream inputStream,
java.io.File file)
Write an input stream to a file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static void saveStream(java.io.InputStream inputStream, java.io.File file) throws java.io.IOException
inputStream
- some stream to be savedfile
- the target file
java.io.IOException
- when file can't be savedpublic static java.lang.String readUrlToString(java.net.URL url) throws java.io.IOException
url
- some url
java.io.IOException
- thrown when ressource cannot
be opened for readingpublic static byte[] readUrlToByteArray(java.net.URL url) throws java.io.IOException
url
- some url
java.io.IOException
- thrown when ressource cannot
be opened for readingpublic static void readInputStream(java.io.OutputStream os, java.io.InputStream is) throws java.io.IOException
os
- some output stream.is
- some input stream.
java.io.IOException
- thrown when reading or
writing failspublic static java.lang.String readInputStream(java.io.InputStream is) throws java.io.IOException
is
- the input stream
java.io.IOException
public static byte[] readInputStreamToByteArray(java.io.InputStream is) throws java.io.IOException
is
- the input stream
java.io.IOException
public static java.util.List getFilesFromDir(java.lang.String aDirectory, java.lang.String aSuffix)
aDirectory
with suffix aSuffix
and
returns them in a List
.
aDirectory
- a String
with the directory nameaSuffix
- a String
with a filename suffix
List
with the filenamespublic static void copyFile(java.io.File source, java.io.File target) throws java.io.IOException
source
- the source File
to copytarget
- the target File
java.io.IOException
public static java.nio.ByteBuffer readFile(java.io.File aFile) throws java.io.FileNotFoundException, java.io.IOException
java.io.FileNotFoundException
java.io.IOException
public static java.lang.String readFileAsString(java.io.File aFile, java.lang.String aCharSet) throws java.io.FileNotFoundException, java.io.IOException, java.nio.charset.UnsupportedCharsetException
aCharSet
- the charset to use for conversion, if null
ISO-8859-15 is used
java.io.FileNotFoundException
java.io.IOException
java.nio.charset.UnsupportedCharsetException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |