|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.resilientedge.util.io.FileHelper
Some file and resource utilities like reading the entire file into a string, reading the file from anywhere in the classpath, etc.
| Constructor Summary | |
FileHelper()
|
|
| Method Summary | |
static java.io.File |
createFile(java.lang.String filePath,
boolean overwrite)
Creates a new file given the string filename... |
static void |
delete(java.lang.String fileName)
Delete the specified file |
static boolean |
exists(java.lang.String fileName)
Does the specified file exist? |
static java.io.InputStream |
getResource(java.lang.String fileName)
Get the input stream of the file whose name is fileName. |
static java.lang.String |
read(java.io.File file)
Read the specified file into a string |
static java.lang.String |
read(java.io.Reader reader)
Read from the specified reader into a string |
static java.lang.String |
read(java.lang.String fileName)
Read the specified file into a string |
static byte[] |
readBytes(java.io.File file)
Read the specified file into a string |
static java.lang.String |
readResource(java.lang.String fileName)
Get the contents of the file whose name is fileName. |
static java.lang.String |
readUrl(java.lang.String url)
Read the specified url into a string |
static java.lang.String |
readUrl(java.net.URL url)
Read the specified url into a string |
static byte[] |
streamToByteArray(java.io.InputStream is)
Read a stream into a byte array |
static void |
write(java.io.File file,
byte[] data)
Write the string to the specified file |
static void |
write(java.io.File file,
java.lang.String data)
Write the string to the specified file |
static void |
write(java.lang.String file,
java.lang.String data)
Write the string to the specified file |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public FileHelper()
| Method Detail |
public static java.io.InputStream getResource(java.lang.String fileName)
throws java.io.IOException
fileName - Parameter Descriptionjava.io.IOException - Exception Descriptionpublic static boolean exists(java.lang.String fileName)
fileName - Parameter Description
public static java.lang.String read(java.lang.String fileName)
throws java.io.IOException
fileName - Parameter Descriptionjava.io.IOException - Exception Description
public static java.lang.String readResource(java.lang.String fileName)
throws java.io.IOException
fileName - Parameter Descriptionjava.io.IOException - Exception Description
public static java.lang.String read(java.io.File file)
throws java.io.IOException
file - Parameter Descriptionjava.io.IOException - Exception Description
public static java.lang.String readUrl(java.lang.String url)
throws java.io.IOException
url - the url to readjava.io.IOException - Description of Exception
public static java.lang.String readUrl(java.net.URL url)
throws java.io.IOException
url - the url to readjava.io.IOException - Description of Exception
public static java.lang.String read(java.io.Reader reader)
throws java.io.IOException
reader - Parameter Descriptionjava.io.IOException - Exception Description
public static void write(java.lang.String file,
java.lang.String data)
throws java.io.IOException
file - Parameter Descriptiondata - Parameter Descriptionjava.io.IOException - Exception Description
public static void write(java.io.File file,
java.lang.String data)
throws java.io.IOException
file - Parameter Descriptiondata - Parameter Descriptionjava.io.IOException - Exception Description
public static void write(java.io.File file,
byte[] data)
throws java.io.IOException
file - Parameter Descriptiondata - Parameter Descriptionjava.io.IOException - Exception Description
public static void delete(java.lang.String fileName)
throws java.io.IOException
fileName - Parameter Descriptionjava.io.IOException - Exception Description
public static byte[] readBytes(java.io.File file)
throws java.io.IOException
file - Parameter Descriptionjava.io.IOException - Exception Descriptionpublic static byte[] streamToByteArray(java.io.InputStream is)
is - Parameter Description
public static java.io.File createFile(java.lang.String filePath,
boolean overwrite)
filePath - the path of the file to create, may include directoriesoverwrite - whether or not to overwite the file if it already exists
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||