|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.varienaja.util.FileOperations
public class FileOperations
Some much-used operations on files. TODO Add a logger, don't print stacktraces.
| Constructor Summary | |
|---|---|
FileOperations()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
copyFile(java.lang.String src,
java.lang.String dstdir,
java.lang.String dst)
Copies a file. |
static void |
copyStream(java.io.InputStream in,
java.io.OutputStream out)
|
static java.lang.String |
createUniqueFilename(java.lang.String dstdir,
java.lang.String dst)
Finds a filename that is not already used. |
static boolean |
deleteDir(java.io.File dir)
Deletes a directory including all contents. |
static boolean |
deleteFile(java.lang.String filename)
Deletes a file from the filesystem. |
static int |
extractToDirectory(TolerantZipInputStream zis,
java.lang.String directory)
Takes a zip-inputstream and extracts the contents to the specified directory. |
static java.lang.String |
moveFile(java.lang.String src,
java.lang.String dstdir,
java.lang.String dst)
Moves a file. |
static java.lang.String |
streamToFile(java.io.InputStream in,
java.io.File file)
Saves an InputStream to a file. |
static java.lang.String |
streamToFile(java.io.InputStream in,
java.lang.String filename)
Saves an InputStream to a file. |
static java.lang.String |
tmpFile(java.io.InputStream in,
java.lang.String tmpname)
Creates a file in the temp-directory and returns the filename |
static java.lang.String |
translateIllegalDirectoryChars(java.lang.String from)
Returns the "from" string with all : * ? " < > | characters replaced with "_". |
static java.lang.String |
translateIllegalFileChars(java.lang.String from)
Returns the "from" string with all / \ : * ? " < > | characters replaced with "_". |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FileOperations()
| Method Detail |
|---|
public static java.lang.String createUniqueFilename(java.lang.String dstdir,
java.lang.String dst)
dstdir - The directory where the file should be created.dst - The desired filename
public static java.lang.String copyFile(java.lang.String src,
java.lang.String dstdir,
java.lang.String dst)
throws java.io.IOException
src - The location of the sourcefile.dstdir - The target directory.dst - The requested filename (without directory-part).
java.io.IOException
public static java.lang.String moveFile(java.lang.String src,
java.lang.String dstdir,
java.lang.String dst)
throws java.io.IOException
src - dstdir - dst -
java.io.IOException
public static void copyStream(java.io.InputStream in,
java.io.OutputStream out)
public static java.lang.String tmpFile(java.io.InputStream in,
java.lang.String tmpname)
throws java.io.IOException
in - The InputStreamtmpname - The filename to use (without path)
java.io.IOException
public static java.lang.String streamToFile(java.io.InputStream in,
java.lang.String filename)
throws java.io.IOException
in - The InputStreamfilename - The file to save the Stream into.
java.io.IOException
public static java.lang.String streamToFile(java.io.InputStream in,
java.io.File file)
throws java.io.IOException
in - The InputStreamfilename - The file to save the Stream into.
java.io.IOExceptionpublic static boolean deleteFile(java.lang.String filename)
filename - The file to delete
public static boolean deleteDir(java.io.File dir)
WARNING: This method will happily delete the contents of your entiry hard drive. Use with extreme care.
dir - The directory to delete.
public static java.lang.String translateIllegalFileChars(java.lang.String from)
from - The source string
public static java.lang.String translateIllegalDirectoryChars(java.lang.String from)
from - The source string
public static int extractToDirectory(TolerantZipInputStream zis,
java.lang.String directory)
zis - The Zip-inputstreamdirectory - The location to unzip to
createUniqueFilename
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||