|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xnap.util.FileHelper
public class FileHelper
Provides a set of static methods that help with file manipulation.
Constructor Summary | |
---|---|
FileHelper()
|
Method Summary | |
---|---|
static java.lang.String |
appendSeparator(java.lang.String path)
Appens a file separator to path if it does not have a
trailing one. |
static void |
copy(java.io.File source,
java.io.File dest)
Copies source to dest . |
static void |
copy(java.io.InputStream inStream,
java.io.OutputStream outStream)
Copies source to dest . |
static java.io.File |
createIncompleteFile(java.lang.String filename)
Creates and returns a file in the incomplete directory. |
static java.io.File |
createUnique(java.io.File path,
java.lang.String filename)
Creates a unique file in by inserting digits into filename . |
static java.io.File |
createUnique(java.lang.String filename)
Creates a unique file by inserting digits into filename . |
static java.lang.String |
directories(java.lang.String dirs)
|
static java.lang.String |
directory(java.lang.String dir)
|
static boolean |
exists(java.lang.String filename)
Returns true, if filename exists; false, otherwise. |
static java.lang.String |
extension(java.lang.String filename)
Returns the lower case extension part of filename . |
static java.lang.String |
getDownloadDir(java.lang.String filename)
Returns the path of the download dir where filename
should be downloaded to. |
static java.lang.String |
getHomeDir()
Returns the absolute path of the ~/.xnap/ directory. |
static java.lang.String |
getHomeDir(java.lang.String subdir)
Checks for existence of .xnap folder in the user's home directory and returns the absolute path with a file separator appended. |
static java.net.URL |
getResource(java.lang.String filename)
|
static java.io.InputStream |
getResourceAsStream(java.lang.String filename)
|
static boolean |
move(java.io.File source,
java.io.File dest)
Moves a file. |
static java.io.File |
moveUnique(java.io.File file,
java.lang.String path)
Moves file to path . |
static java.io.File |
moveUnique(java.io.File file,
java.lang.String path,
java.lang.String filename)
Moves file to path but renames
filename if it already exists in the target path. |
static java.lang.String |
name(java.lang.String filename)
Returns the name part of filename . |
static void |
readBinary(java.io.File file,
java.util.Collection c)
Reads all objects from file using serialization and adds
them to c . |
static java.lang.String[] |
readConfig(java.io.File file)
|
static java.lang.String[] |
readConfig(java.io.InputStream inStream)
Reads a text file. |
static java.lang.String |
readText(java.io.File file)
|
static java.lang.String |
readText(java.io.InputStream inStream)
Reads a text file. |
static void |
shorten(java.io.File file,
long bytes)
Shortens file by bytes bytes. |
static java.lang.String |
toAscii(java.lang.String filename)
Replaces all special characters in filename by '_'. |
static java.lang.String |
toFilename(java.lang.String filename)
Replaces some special characters in filename by '_'. |
static java.lang.String |
uniqueName(java.lang.String filename)
Creates unique filename. |
static java.lang.String |
uniqueName(java.lang.String filename,
java.lang.String infix)
|
static void |
writeBinary(java.io.File file,
java.util.Collection c)
Write all items in c to file using
serialization. |
static void |
writeProperties(java.io.File file,
java.util.Properties props)
Stores props in file . |
static void |
writeText(java.io.File file,
java.lang.String text)
Writes a text 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.File createIncompleteFile(java.lang.String filename) throws java.io.IOException
java.io.IOException
public static java.io.File createUnique(java.lang.String filename) throws java.io.IOException
filename
.
java.io.IOException
public static java.io.File createUnique(java.io.File path, java.lang.String filename) throws java.io.IOException
filename
.
path
- the path of the file to createfilename
- the name of the file to create
java.io.IOException
public static java.io.File moveUnique(java.io.File file, java.lang.String path, java.lang.String filename) throws java.io.IOException
file
to path
but renames
filename
if it already exists in the target path.
file
- the file to movepath
- the target pathfilename
- the new filename for file
java.io.IOException
public static java.io.File moveUnique(java.io.File file, java.lang.String path) throws java.io.IOException
file
to path
.
java.io.IOException
moveUnique(File, String, String)
public static boolean move(java.io.File source, java.io.File dest) throws java.io.IOException
java.io.IOException
public static void copy(java.io.File source, java.io.File dest) throws java.io.IOException
source
to dest
. If dest already exists
it is overwritten.
source
- the source filedest
- the destination file
java.io.IOException
public static void copy(java.io.InputStream inStream, java.io.OutputStream outStream) throws java.io.IOException
source
to dest
. If dest already exists
it is overwritten.
source
- the source filedest
- the destination file
java.io.IOException
public static java.lang.String extension(java.lang.String filename)
filename
.
name(String)
public static java.lang.String name(java.lang.String filename)
filename
.
extension(String)
public static java.lang.String getDownloadDir(java.lang.String filename)
filename
should be downloaded to.
public static java.net.URL getResource(java.lang.String filename)
public static java.io.InputStream getResourceAsStream(java.lang.String filename)
public static java.lang.String uniqueName(java.lang.String filename)
public static java.lang.String uniqueName(java.lang.String filename, java.lang.String infix)
public static boolean exists(java.lang.String filename)
public static final java.lang.String getHomeDir(java.lang.String subdir)
subdir
- a sub directory that is located in ~/.xnap/ or created if
it does not exist
public static final java.lang.String getHomeDir()
getHomeDir(String)
public static java.lang.String appendSeparator(java.lang.String path)
path
if it does not have a
trailing one.
public static java.lang.String directory(java.lang.String dir)
public static java.lang.String directories(java.lang.String dirs)
public static void shorten(java.io.File file, long bytes)
file
by bytes
bytes.
public static void writeProperties(java.io.File file, java.util.Properties props) throws java.io.IOException
props
in file
.
java.io.IOException
public static void readBinary(java.io.File file, java.util.Collection c) throws java.io.IOException
file
using serialization and adds
them to c
.
java.io.IOException
public static java.lang.String readText(java.io.File file) throws java.io.IOException
java.io.IOException
public static java.lang.String readText(java.io.InputStream inStream) throws java.io.IOException
java.io.IOException
public static java.lang.String[] readConfig(java.io.File file) throws java.io.IOException
java.io.IOException
public static java.lang.String[] readConfig(java.io.InputStream inStream) throws java.io.IOException
java.io.IOException
public static java.lang.String toAscii(java.lang.String filename)
public static java.lang.String toFilename(java.lang.String filename)
public static void writeBinary(java.io.File file, java.util.Collection c) throws java.io.IOException
c
to file
using
serialization.
java.io.IOException
public static void writeText(java.io.File file, java.lang.String text) throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |