public abstract class IOUtils extends java.lang.Object
| Constructor and Description |
|---|
IOUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
closeSafely(java.io.Closeable... objects)
Close a list of resources.
|
static void |
copyCharStream(java.io.Reader reader,
java.io.Writer writer)
Copies an char input stream into an char output stream.
|
static void |
copyStream(java.io.InputStream is,
java.io.OutputStream os)
Copies an inputstream into an output stream.
|
static java.io.File |
createJar(java.io.File baseDir,
java.lang.String jarName,
java.lang.Class... classes)
Creates a JAR file with the specified classes.
|
static void |
delete(java.io.File file)
Delete recursively a local directory.
|
static java.lang.String |
getReaderAsString(java.io.Reader reader,
int maxLen)
Return a reader as string.
|
static java.io.Reader |
getResourceAsReader(java.lang.String path,
int maxLen)
Return a classpath resource as a reader.
|
static java.io.InputStream |
getResourceAsStream(java.lang.String path,
int maxLen)
Return a classpath resource as a stream.
|
static java.lang.String |
getResourceAsString(java.lang.String path,
int maxLen)
Return a classpath resource as string.
|
static void |
zipDir(java.io.File dir,
java.lang.String relativePath,
java.util.zip.ZipOutputStream zos)
Zips a local directory, recursively, into a ZIP stream.
|
public IOUtils()
public static void delete(java.io.File file) throws java.io.IOException
file - directory to delete.java.io.IOException - thrown if the directory could not be deleted.public static java.lang.String getReaderAsString(java.io.Reader reader, int maxLen) throws java.io.IOException
reader - reader to read into a string.maxLen - max content length allowed, if -1 there is no limit.java.io.IOException - thrown if the resource could not be read.public static java.io.InputStream getResourceAsStream(java.lang.String path, int maxLen) throws java.io.IOException
path - classpath for the resource.maxLen - max content length allowed.java.io.IOException - thrown if the resource could not be read.public static java.io.Reader getResourceAsReader(java.lang.String path, int maxLen) throws java.io.IOException
path - classpath for the resource.maxLen - max content length allowed.java.io.IOException - thrown if the resource could not be read.public static java.lang.String getResourceAsString(java.lang.String path, int maxLen) throws java.io.IOException
path - classpath for the resource.maxLen - max content length allowed.java.io.IOException - thrown if the resource could not be read.public static void copyStream(java.io.InputStream is, java.io.OutputStream os) throws java.io.IOException
is - inputstream to copy from.os - outputstream to copy to.java.io.IOException - thrown if the copy failed.public static void copyCharStream(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
reader - reader to copy from.writer - writer to copy to.java.io.IOException - thrown if the copy failed.public static void zipDir(java.io.File dir, java.lang.String relativePath, java.util.zip.ZipOutputStream zos) throws java.io.IOException
dir - directory to ZIP.relativePath - basePath in the ZIP for the files, normally "/".zos - the ZIP output stream to ZIP the directory.java.io.IOException - thrown if the directory could not be zipped.public static java.io.File createJar(java.io.File baseDir, java.lang.String jarName, java.lang.Class... classes) throws java.io.IOException
baseDir - local directory to create the JAR file, the staging 'classes' directory is created in there.jarName - JAR file name, including extesion.classes - classes to add to the JAR.java.io.IOException - thrown if the JAR file could not be created.public static void closeSafely(java.io.Closeable... objects)
objects - list of objects to closeCopyright © 2018 Apache Software Foundation. All Rights Reserved.