|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.zkoss.io.Files
public class Files
File related utilities.
Field Summary | |
---|---|
static int |
CP_OVERWRITE
Overwrites the destination file. |
static int |
CP_PRESERVE
Preserves the last modified time and other attributes if possible. |
static int |
CP_SKIP_SVN
Skips the SVN related files. |
static int |
CP_UPDATE
Copy only when the source is newer or when the destination is missing. |
static char |
DRIVE_SEPARATOR_CHAR
The separator representing the drive in a path. |
Constructor Summary | |
---|---|
protected |
Files()
|
Method Summary | |
---|---|
static void |
close(java.io.InputStream strm)
Close an input stream without throwing an exception. |
static void |
close(java.io.OutputStream strm)
Close an output stream without throwing an exception. |
static void |
close(java.io.Reader reader)
Close a reader without throwing an exception. |
static void |
close(java.io.Writer writer)
Close a writer without throwing an exception. |
static void |
copy(java.io.File dst,
java.io.File src,
int flags)
Copies a file or a directory into another. |
static void |
copy(java.io.File dst,
java.io.InputStream in)
Copies an input stream into a file (the original content, if any, are erased). |
static void |
copy(java.io.File dst,
java.io.Reader reader,
java.lang.String charset)
Copies a reader into a file (the original content, if any, are erased). |
static void |
copy(java.io.OutputStream out,
java.io.InputStream in)
Copies an input stream to a output stream. |
static void |
copy(java.io.Writer writer,
java.io.Reader reader)
Copies a reader into a writer. |
static java.lang.String |
correctSeparator(java.lang.String flnm)
Corrects the separator from '/' to the system dependent one. |
static boolean |
deleteAll(java.io.File file)
Deletes all files under the specified path. |
static java.lang.String |
locate(java.lang.String flnm)
Locates a file based o the current Locale. |
static java.lang.String |
normalize(java.lang.String path)
Normalizes the specified path. |
static java.lang.String |
normalize(java.lang.String parentPath,
java.lang.String childPath)
Normalizes the catenation of two paths. |
static byte[] |
readAll(java.io.InputStream in)
Returns all bytes in the input stream, never null (but its length might zero). |
static java.lang.StringBuffer |
readAll(java.io.Reader reader)
Returns all characters in the reader, never null (but its length might zero). |
static void |
write(java.io.Writer out,
java.lang.StringBuffer sb)
Writes the specified string buffer to the specified writer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final char DRIVE_SEPARATOR_CHAR
public static int CP_PRESERVE
copy(File, File, int)
public static int CP_UPDATE
copy(File, File, int)
public static int CP_OVERWRITE
copy(File, File, int)
public static int CP_SKIP_SVN
Constructor Detail |
---|
protected Files()
Method Detail |
---|
public static final java.lang.String correctSeparator(java.lang.String flnm)
public static final byte[] readAll(java.io.InputStream in) throws java.io.IOException
Notice: this method is memory hungry.
Notice: it doesn't close in
java.io.IOException
public static final java.lang.StringBuffer readAll(java.io.Reader reader) throws java.io.IOException
Notice: this method is memory hungry.
java.io.IOException
public static final void copy(java.io.Writer writer, java.io.Reader reader) throws java.io.IOException
Notice: it doesn't close reader
or writer
writer
- the destinationreader
- the source
java.io.IOException
public static final void copy(java.io.OutputStream out, java.io.InputStream in) throws java.io.IOException
Notice: it doesn't close in
or out
out
- the destinationin
- the source
java.io.IOException
public static final void copy(java.io.File dst, java.io.Reader reader, java.lang.String charset) throws java.io.IOException
dst
- the destinationreader
- the sourcecharset
- the charset; null as default (ISO-8859-1).
java.io.IOException
public static final void copy(java.io.File dst, java.io.InputStream in) throws java.io.IOException
dst
- the destinationin
- the source
java.io.IOException
public static final void copy(java.io.File dst, java.io.File src, int flags) throws java.io.IOException
If neither CP_UPDATE
nor CP_OVERWRITE
,
IOException is thrown if the destination exists.
flags
- any combination of CP_UPDATE
, CP_PRESERVE
,
CP_OVERWRITE
.
java.io.IOException
public static final boolean deleteAll(java.io.File file)
public static final void close(java.io.InputStream strm)
public static final void close(java.io.Reader reader)
public static final void close(java.io.OutputStream strm)
public static final void close(java.io.Writer writer)
public static final java.lang.String normalize(java.lang.String parentPath, java.lang.String childPath)
parentPath
- the parent's pathchildPath
- the child's path
If it starts with "/", parentPath is ignored.public static final java.lang.String normalize(java.lang.String path)
Unlike File
, normalize(java.lang.String, java.lang.String)
always assumes
the separator to be '/', and it cannot handle the device prefix
(e.g., c:). However, it handles //.
path
- the path to normalize. If null, an empty string is returned.public static final void write(java.io.Writer out, java.lang.StringBuffer sb) throws java.io.IOException
java.io.IOException
public static final java.lang.String locate(java.lang.String flnm)
If the filename contains "*", it will be replaced with a proper Locale. For example, if the current Locale is zh_TW and the resource is named "ab*.cd", then it searches "ab_zh_TW.cd", "ab_zh.cd" and then "ab.cd", until any of them is found.
Note: "*" must be right before ".", or the last character. For example, "ab*.cd" and "ab*" are both correct, while "ab*cd" and "ab*\/cd" are ignored.
Unlike Locators.locate(java.lang.String, java.util.Locale, org.zkoss.util.resource.Locator)
, the filename
must contain '*', while Locators.locate(java.lang.String, java.util.Locale, org.zkoss.util.resource.Locator)
always tries to locate the file by
inserting the locale before '.'. In other words,
Files.locate("/a/b*.c") is similar to
Locators.locate(("/a/b.c", null, a_file_locator);
flnm
- the filename to locate. If it doesn't contain any '*',
it is returned directly. If the file is not found, flnm is returned, too.Locales.getCurrent()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |