|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.webmethods.caf.common.FileUtil
public class FileUtil
Parts taken from com.webmethods.portal.common.util.FileUtil Used to get a file input to a users specific needs as different formats and grab a file from different locations taking into account errors the user might have made.
Field Summary | |
---|---|
static String |
BACKWARD_SLASH
Standard backslash |
protected static String |
m_tempDirectory
|
Constructor Summary | |
---|---|
FileUtil()
|
Method Summary | |
---|---|
static int |
copyStream(InputStream inputStream,
OutputStream outputStream)
Copies all the bits from the inputStream to the ouputStream |
static File |
createTempDir()
Atomically creates a new directory somewhere beneath the system's temporary directory (as defined by the java.io.tmpdir system
property), and returns its name. |
static String |
ensureForwardSlashes(String path)
Changes backward slashes to forward slashes. |
static String |
ensureTrailingSlash(String path)
Ensures the directory path has trailing slash |
static byte[] |
getContentToBytes(InputStream inStream)
Reads entire file into byte array. |
static String |
getContentToString(InputStream inStream)
Reads entire file into the string |
static String |
getTempDirectory()
Returns the system's temporary directory. |
static String |
normalizeFileName(String fileName)
Any character in the filename that is not a dot, letter or digit is replaced with '_' |
static void |
removeDir(File dir)
Removes the folder with all files and subfolders |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static String m_tempDirectory
FileUtil.getTempDirectory()
public static final String BACKWARD_SLASH
Constructor Detail |
---|
public FileUtil()
Method Detail |
---|
public static String getContentToString(InputStream inStream) throws IOException
inStream
- InputStream to be converted to String
IOException
- conversion failspublic static byte[] getContentToBytes(InputStream inStream) throws IOException
inStream
- InputStream to be converted to byte[]
IOException
- conversion failurepublic static String getTempDirectory() throws IOException
IOException
public static String ensureTrailingSlash(String path)
path
- temporary directory path
public static String ensureForwardSlashes(String path)
path
- string to modify
public static String normalizeFileName(String fileName)
fileName
- the source filename
public static int copyStream(InputStream inputStream, OutputStream outputStream) throws IOException
inputStream
- the source of the bits to be copiedoutputStream
- the destination for the copied bits.
IOException
public static void removeDir(File dir) throws IOException
IOException
public static File createTempDir()
java.io.tmpdir
system
property), and returns its name.
Use this method instead of File.createTempFile(String, String)
when you wish to create a directory, not a regular file. A common pitfall
is to call createTempFile
, delete the file and create a
directory in its place, but this leads a race condition which can be
exploited to create security vulnerabilities, especially when executable
files are to be written into the directory.
This method assumes that the temporary volume is writable, has free inodes and free blocks, and that it will not be called thousands of times per second.
IllegalStateException
- if the directory could not be created
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |