|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.clapper.util.io.FileUtil
public class FileUtil
Static class containing miscellaneous file utility methods.
| Method Summary | |
|---|---|
static java.lang.String |
basename(java.io.File file)
Get the base (i.e., simple file) name of a file. |
static java.lang.String |
basename(java.lang.String fileName)
Get the base (i.e., simple file) name of a file. |
static int |
copyFile(java.io.File src,
java.io.File dst)
Copy one file to another. |
static int |
copyReader(java.io.Reader reader,
java.io.Writer writer)
Copy characters from a reader to a writer, using a default buffer size. |
static int |
copyReader(java.io.Reader reader,
java.io.Writer writer,
int bufferSize)
Copy characters from a reader to a writer. |
static int |
copyStream(java.io.InputStream is,
java.io.OutputStream os)
Copy an InputStream to an OutputStream. |
static int |
copyStream(java.io.InputStream src,
java.io.OutputStream dst,
int bufferSize)
Copy an InputStream to an OutputStream. |
static int |
copyTextFile(java.io.File src,
java.lang.String srcEncoding,
java.io.File dst,
java.lang.String dstEncoding)
Copy one file to another, character by character, possibly doing character set conversions |
static java.lang.String |
dirname(java.io.File file)
Get the name of a file's parent directory. |
static java.lang.String |
dirname(java.lang.String fileName)
Get the name of a file's parent directory. |
static java.lang.String |
getDefaultEncoding()
Get the virtual machine's default encoding. |
static java.lang.String |
getFileNameExtension(java.io.File file)
Get the extension for a path or file name. |
static java.lang.String |
getFileNameExtension(java.lang.String path)
Get the extension for a path or file name. |
static java.lang.String |
getFileNameNoExtension(java.io.File file)
Get the name of a file without its extension. |
static java.lang.String |
getFileNameNoExtension(java.lang.String path)
Get the name of a file without its extension. |
static boolean |
isAbsolutePath(java.lang.String path)
Determine whether a string represents an absolute path. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean isAbsolutePath(java.lang.String path)
throws java.io.IOException
path - the path to check
java.io.IOException - on error
public static int copyStream(java.io.InputStream is,
java.io.OutputStream os)
throws java.io.IOException
copyStream (src, dst, 8192);
is - the source InputStreamos - the destination OutputStream
java.io.IOException - on errorcopyStream(InputStream,OutputStream,int),
copyReader(Reader,Writer),
copyFile(File,File)
public static int copyStream(java.io.InputStream src,
java.io.OutputStream dst,
int bufferSize)
throws java.io.IOException
src - the source InputStreamdst - the destination OutputStreambufferSize - the buffer size to use, or -1 for a default
java.io.IOException - on errorcopyReader(Reader,Writer,int),
copyStream(InputStream,OutputStream),
copyFile(File,File)
public static int copyReader(java.io.Reader reader,
java.io.Writer writer,
int bufferSize)
throws java.io.IOException
reader - where to read fromwriter - where to write tobufferSize - buffer size to use, if reader and writer are not
already buffered, or -1 to use a default size.
java.io.IOException - on errorcopyReader(Reader,Writer),
copyStream(InputStream,OutputStream,int),
copyStream(InputStream,OutputStream),
copyFile(File,File)
public static int copyReader(java.io.Reader reader,
java.io.Writer writer)
throws java.io.IOException
reader - where to read fromwriter - where to write to
java.io.IOException - on errorcopyReader(Reader,Writer),
copyStream(InputStream,OutputStream,int),
copyStream(InputStream,OutputStream),
copyFile(File,File)
public static int copyFile(java.io.File src,
java.io.File dst)
throws java.io.IOException
copyTextFile(File,String,File,String).
src - The file to copydst - Where to copy it. Can be a directory or a file.
java.io.IOException - on errorcopyTextFile(File,String,File,String),
copyReader(Reader,Writer,int),
copyReader(Reader,Writer),
copyStream(InputStream,OutputStream,int),
copyStream(InputStream,OutputStream)
public static int copyTextFile(java.io.File src,
java.lang.String srcEncoding,
java.io.File dst,
java.lang.String dstEncoding)
throws java.io.IOException
src - the file to copysrcEncoding - the character set encoding for the source file,
or null to assume the defaultdst - Where to copy it. Can be a directory or a file.dstEncoding - the character set encoding for the destination file,
or null to assume the default
java.io.IOException - on errorcopyFile(File,File),
copyReader(Reader,Writer,int),
copyReader(Reader,Writer),
copyStream(InputStream,OutputStream,int),
copyStream(InputStream,OutputStream)public static java.lang.String getDefaultEncoding()
public static java.lang.String getFileNameExtension(java.io.File file)
file - the file
public static java.lang.String getFileNameExtension(java.lang.String path)
path - the file or path name
public static java.lang.String getFileNameNoExtension(java.io.File file)
file - the file
public static java.lang.String getFileNameNoExtension(java.lang.String path)
path - the path
public static java.lang.String dirname(java.lang.String fileName)
fileName - the file name
dirname(File),
basename(String)public static java.lang.String dirname(java.io.File file)
file - the file whose parent directory is to be returned
dirname(String),
basename(File)public static java.lang.String basename(java.lang.String fileName)
fileName - name of the file to get the basename for
dirname(String)public static java.lang.String basename(java.io.File file)
file - the file to get the basename for
basename(String),
dirname(File)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||