Package hudson.util
Class IOUtils
java.lang.Object
hudson.util.IOUtils
Adds more to commons-io.
- Since:
- 1.337
- Author:
- Kohsuke Kawaguchi
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Fileabsolutize(File base, String path) Resolves the given path with respect to given base.static voidcloseQuietly(InputStream input) Deprecated.static voidcloseQuietly(OutputStream output) Deprecated.Use Java 7try-with-resources instead.static voidcloseQuietly(Reader input) Deprecated.Use Java 7try-with-resources instead.static voidcloseQuietly(Writer output) Deprecated.Use Java 7try-with-resources instead.static booleancontentEquals(InputStream input1, InputStream input2) Deprecated.Use insteadIOUtils.contentEquals(java.io.InputStream, java.io.InputStream)static booleancontentEquals(Reader input1, Reader input2) Deprecated.Use insteadIOUtils.contentEquals(java.io.Reader, java.io.Reader)static voidcopy(File src, OutputStream out) static voidcopy(InputStream in, File out) static intcopy(InputStream input, OutputStream output) Deprecated.Use insteadIOUtils.copy(java.io.InputStream, java.io.OutputStream)static voidcopy(InputStream input, Writer output) Deprecated.Use insteadIOUtils.copy(java.io.InputStream, java.io.Writer)static voidcopy(InputStream input, Writer output, String encoding) Deprecated.Use insteadIOUtils.copy(java.io.InputStream, java.io.Writer, String)static voidcopy(Reader input, OutputStream output) Deprecated.Use insteadIOUtils.copy(java.io.Reader, java.io.OutputStream)static voidcopy(Reader input, OutputStream output, String encoding) Deprecated.Use insteadIOUtils.copy(java.io.Reader, java.io.OutputStream, String)static intDeprecated.Use insteadIOUtils.copy(java.io.Reader, java.io.Writer)static longcopyLarge(InputStream input, OutputStream output) Deprecated.Use insteadIOUtils.copyLarge(java.io.InputStream, java.io.OutputStream)static longDeprecated.Use insteadIOUtils.copyLarge(java.io.Reader, java.io.Writer)static voiddrain(InputStream in) Drains the input stream and closes it.static booleanisAbsolute(String path) SeeFilePath.isAbsolute(String).static org.apache.commons.io.LineIteratorlineIterator(InputStream input, String encoding) Deprecated.Use insteadIOUtils.lineIterator(java.io.InputStream, String)static org.apache.commons.io.LineIteratorlineIterator(Reader reader) Deprecated.Use insteadIOUtils.lineIterator(java.io.Reader)static FileEnsures that the given directory exists (if not, it's created, including all the parent directories.)static intGets the mode of a file/directory, if appropriate.static StringreadFirstLine(InputStream is, String encoding) Read the first line of the given stream, close it, and return that line.static ListreadLines(InputStream input) Deprecated.Use insteadIOUtils.readLines(java.io.InputStream)static ListreadLines(InputStream input, String encoding) Deprecated.Use insteadIOUtils.readLines(java.io.InputStream, String)static ListDeprecated.Use insteadIOUtils.readLines(java.io.Reader)static InputStreamskip(InputStream in, long size) Deprecated.useIOUtils.skipFully(InputStream, long)static byte[]toByteArray(InputStream input) Deprecated.Use insteadIOUtils.toByteArray(java.io.InputStream)static byte[]toByteArray(Reader input) Deprecated.Use insteadIOUtils.toByteArray(java.io.Reader)static byte[]toByteArray(Reader input, String encoding) Deprecated.Use insteadIOUtils.toByteArray(java.io.Reader, String)static byte[]toByteArray(String input) Deprecated.Use insteadIOUtils.toByteArray(String)static char[]Deprecated.Use insteadIOUtils.toCharArray(java.io.InputStream)static char[]toCharArray(InputStream is, String encoding) Deprecated.Use insteadIOUtils.toCharArray(java.io.InputStream, String)static char[]toCharArray(Reader input) Deprecated.Use insteadIOUtils.toCharArray(java.io.Reader)static InputStreamtoInputStream(String input) Deprecated.Use insteadIOUtils.toInputStream(String)static InputStreamtoInputStream(String input, String encoding) Deprecated.Use insteadIOUtils.toInputStream(String, String)static StringtoString(byte[] input) Deprecated.Use insteadIOUtils.toString(byte[])static StringDeprecated.Use insteadIOUtils.toString(byte[], String)static StringtoString(InputStream input) Deprecated.Use insteadIOUtils.toString(java.io.InputStream)static StringtoString(InputStream input, String encoding) Deprecated.Use insteadIOUtils.toString(java.io.InputStream, String)static StringDeprecated.Use insteadIOUtils.toString(java.io.Reader)static voidwrite(byte[] data, OutputStream output) Deprecated.Use insteadIOUtils.write(byte[], java.io.OutputStream)static voidDeprecated.Use insteadIOUtils.write(byte[], java.io.Writer)static voidDeprecated.Use insteadIOUtils.write(byte[], java.io.Writer, String)static voidwrite(char[] data, OutputStream output) Deprecated.Use insteadIOUtils.write(char[], java.io.OutputStream)static voidwrite(char[] data, OutputStream output, String encoding) Deprecated.Use insteadIOUtils.write(char[], java.io.OutputStream, String)static voidDeprecated.Use insteadIOUtils.write(char[], java.io.OutputStream)static voidwrite(StringBuffer data, OutputStream output) Deprecated.Use insteadIOUtils.write(StringBuffer, java.io.OutputStream)static voidwrite(StringBuffer data, OutputStream output, String encoding) Deprecated.Use insteadIOUtils.write(StringBuffer, java.io.OutputStream, String)static voidwrite(StringBuffer data, Writer output) Deprecated.Use insteadIOUtils.write(StringBuffer, java.io.Writer)static voidwrite(String data, OutputStream output) Deprecated.Use insteadIOUtils.write(String, java.io.OutputStream)static voidwrite(String data, OutputStream output, String encoding) Deprecated.Use insteadIOUtils.write(String, java.io.OutputStream, String)static voidDeprecated.Use insteadIOUtils.write(char[], java.io.Writer)static voidwriteLines(Collection lines, String lineEnding, OutputStream output) Deprecated.Use insteadIOUtils.writeLines(java.util.Collection, String, java.io.OutputStream)static voidwriteLines(Collection lines, String lineEnding, OutputStream output, String encoding) Deprecated.Use insteadIOUtils.writeLines(java.util.Collection, String, java.io.OutputStream, String)static voidwriteLines(Collection lines, String lineEnding, Writer writer) Deprecated.Use insteadIOUtils.writeLines(java.util.Collection, String, java.io.Writer)
-
Constructor Details
-
IOUtils
public IOUtils()
-
-
Method Details
-
drain
Drains the input stream and closes it.- Throws:
IOException
-
copy
- Throws:
IOException
-
copy
- Throws:
IOException
-
mkdirs
Ensures that the given directory exists (if not, it's created, including all the parent directories.)- Returns:
- This method returns the 'dir' parameter so that the method call flows better.
- Throws:
IOException
-
skip
Deprecated.useIOUtils.skipFully(InputStream, long)Fully skips the specified size from the given input stream.InputStream.skip(long)has two problems. One is that it doesn't let us reliably differentiate "hit EOF" case vs "inputstream just returning 0 since there's no data currently available at hand", and some subtypes (such asFileInputStream.skip(long)returning -1.So to reliably skip just the N bytes, we'll actually read all those bytes.
- Throws:
IOException- Since:
- 1.349
-
absolutize
Resolves the given path with respect to given base. If the path represents an absolute path, a file representing it is returned, otherwise a file representing a path relative to base is returned.It would be nice if File#File(File, String) were doing this.
- Parameters:
base- File that represents the parent, may be null if path is absolutepath- Path of the file, may not be null- Returns:
- new File(name) if name represents an absolute path, new File(base, name) otherwise
- See Also:
-
isAbsolute
SeeFilePath.isAbsolute(String).- Parameters:
path- String representingPlatform Specific(unlike FilePath, which may get Platform agnostic paths), may not be null- Returns:
- true if String represents absolute path on this platform, false otherwise
-
mode
Gets the mode of a file/directory, if appropriate. Only includes read, write, and execute permissions for the owner, group, and others, i.e. the max return value is 0777. Consider usingFiles.getPosixFilePermissions(java.nio.file.Path, java.nio.file.LinkOption...)instead if you only care about access permissions.If the file is symlink, the mode is that of the link target, not the link itself.
- Returns:
- a file mode, or -1 if not on Unix
- Throws:
IOException- if the file could not be statted, e.g. broken symlink
-
readFirstLine
Read the first line of the given stream, close it, and return that line.- Parameters:
encoding- If null, use the platform default encoding.- Throws:
IOException- Since:
- 1.422
-
closeQuietly
Deprecated.Use Java 7try-with-resources instead. -
closeQuietly
Deprecated.Use Java 7try-with-resources instead. -
closeQuietly
Deprecated.Use Java 7try-with-resources instead. -
closeQuietly
Deprecated.Use Java 7try-with-resources instead. -
toByteArray
Deprecated.Use insteadIOUtils.toByteArray(java.io.InputStream)- Throws:
IOException
-
toByteArray
Deprecated.Use insteadIOUtils.toByteArray(java.io.Reader)- Throws:
IOException
-
toByteArray
Deprecated.Use insteadIOUtils.toByteArray(java.io.Reader, String)- Throws:
IOException
-
toByteArray
Deprecated.Use insteadIOUtils.toByteArray(String)- Throws:
IOException
-
toCharArray
Deprecated.Use insteadIOUtils.toCharArray(java.io.InputStream)- Throws:
IOException
-
toCharArray
Deprecated.Use insteadIOUtils.toCharArray(java.io.InputStream, String)- Throws:
IOException
-
toCharArray
Deprecated.Use insteadIOUtils.toCharArray(java.io.Reader)- Throws:
IOException
-
toString
Deprecated.Use insteadIOUtils.toString(java.io.InputStream)- Throws:
IOException
-
toString
Deprecated.Use insteadIOUtils.toString(java.io.InputStream, String)- Throws:
IOException
-
toString
Deprecated.Use insteadIOUtils.toString(java.io.Reader)- Throws:
IOException
-
toString
Deprecated.Use insteadIOUtils.toString(byte[])- Throws:
IOException
-
toString
Deprecated.Use insteadIOUtils.toString(byte[], String)- Throws:
IOException
-
readLines
Deprecated.Use insteadIOUtils.readLines(java.io.InputStream)- Throws:
IOException
-
readLines
Deprecated.Use insteadIOUtils.readLines(java.io.InputStream, String)- Throws:
IOException
-
readLines
Deprecated.Use insteadIOUtils.readLines(java.io.Reader)- Throws:
IOException
-
lineIterator
Deprecated.Use insteadIOUtils.lineIterator(java.io.Reader) -
lineIterator
@Deprecated public static org.apache.commons.io.LineIterator lineIterator(InputStream input, String encoding) throws IOException Deprecated.Use insteadIOUtils.lineIterator(java.io.InputStream, String)- Throws:
IOException
-
toInputStream
Deprecated.Use insteadIOUtils.toInputStream(String) -
toInputStream
@Deprecated public static InputStream toInputStream(String input, String encoding) throws IOException Deprecated.Use insteadIOUtils.toInputStream(String, String)- Throws:
IOException
-
write
Deprecated.Use insteadIOUtils.write(byte[], java.io.OutputStream)- Throws:
IOException
-
write
Deprecated.Use insteadIOUtils.write(byte[], java.io.Writer)- Throws:
IOException
-
write
@Deprecated public static void write(byte[] data, Writer output, String encoding) throws IOException Deprecated.Use insteadIOUtils.write(byte[], java.io.Writer, String)- Throws:
IOException
-
write
Deprecated.Use insteadIOUtils.write(char[], java.io.OutputStream)- Throws:
IOException
-
write
Deprecated.Use insteadIOUtils.write(char[], java.io.OutputStream)- Throws:
IOException
-
write
@Deprecated public static void write(char[] data, OutputStream output, String encoding) throws IOException Deprecated.Use insteadIOUtils.write(char[], java.io.OutputStream, String)- Throws:
IOException
-
write
Deprecated.Use insteadIOUtils.write(char[], java.io.Writer)- Throws:
IOException
-
write
Deprecated.Use insteadIOUtils.write(String, java.io.OutputStream)- Throws:
IOException
-
write
@Deprecated public static void write(String data, OutputStream output, String encoding) throws IOException Deprecated.Use insteadIOUtils.write(String, java.io.OutputStream, String)- Throws:
IOException
-
write
Deprecated.Use insteadIOUtils.write(StringBuffer, java.io.Writer)- Throws:
IOException
-
write
Deprecated.Use insteadIOUtils.write(StringBuffer, java.io.OutputStream)- Throws:
IOException
-
write
@Deprecated public static void write(StringBuffer data, OutputStream output, String encoding) throws IOException Deprecated.Use insteadIOUtils.write(StringBuffer, java.io.OutputStream, String)- Throws:
IOException
-
writeLines
@Deprecated public static void writeLines(Collection lines, String lineEnding, OutputStream output) throws IOException Deprecated.Use insteadIOUtils.writeLines(java.util.Collection, String, java.io.OutputStream)- Throws:
IOException
-
writeLines
@Deprecated public static void writeLines(Collection lines, String lineEnding, OutputStream output, String encoding) throws IOException Deprecated.Use insteadIOUtils.writeLines(java.util.Collection, String, java.io.OutputStream, String)- Throws:
IOException
-
writeLines
@Deprecated public static void writeLines(Collection lines, String lineEnding, Writer writer) throws IOException Deprecated.Use insteadIOUtils.writeLines(java.util.Collection, String, java.io.Writer)- Throws:
IOException
-
copy
Deprecated.Use insteadIOUtils.copy(java.io.InputStream, java.io.OutputStream)- Throws:
IOException
-
copyLarge
Deprecated.Use insteadIOUtils.copyLarge(java.io.InputStream, java.io.OutputStream)- Throws:
IOException
-
copy
Deprecated.Use insteadIOUtils.copy(java.io.InputStream, java.io.Writer)- Throws:
IOException
-
copy
@Deprecated public static void copy(InputStream input, Writer output, String encoding) throws IOException Deprecated.Use insteadIOUtils.copy(java.io.InputStream, java.io.Writer, String)- Throws:
IOException
-
copy
Deprecated.Use insteadIOUtils.copy(java.io.Reader, java.io.Writer)- Throws:
IOException
-
copyLarge
Deprecated.Use insteadIOUtils.copyLarge(java.io.Reader, java.io.Writer)- Throws:
IOException
-
copy
Deprecated.Use insteadIOUtils.copy(java.io.Reader, java.io.OutputStream)- Throws:
IOException
-
copy
@Deprecated public static void copy(Reader input, OutputStream output, String encoding) throws IOException Deprecated.Use insteadIOUtils.copy(java.io.Reader, java.io.OutputStream, String)- Throws:
IOException
-
contentEquals
@Deprecated public static boolean contentEquals(InputStream input1, InputStream input2) throws IOException Deprecated.Use insteadIOUtils.contentEquals(java.io.InputStream, java.io.InputStream)- Throws:
IOException
-
contentEquals
Deprecated.Use insteadIOUtils.contentEquals(java.io.Reader, java.io.Reader)- Throws:
IOException
-
try-with-resources instead.