public class IOUtils extends Object
Modifier and Type | Field and Description |
---|---|
static char |
DIR_SEPARATOR
Deprecated.
Use instead
IOUtils.DIR_SEPARATOR |
static char |
DIR_SEPARATOR_UNIX
Deprecated.
Use instead
IOUtils.DIR_SEPARATOR_UNIX |
static char |
DIR_SEPARATOR_WINDOWS
Deprecated.
Use instead
IOUtils.DIR_SEPARATOR_WINDOWS |
static String |
LINE_SEPARATOR
Deprecated.
Use instead
IOUtils.LINE_SEPARATOR |
static String |
LINE_SEPARATOR_UNIX
Deprecated.
Use instead
IOUtils.LINE_SEPARATOR_UNIX |
static String |
LINE_SEPARATOR_WINDOWS
Deprecated.
Use instead
IOUtils.LINE_SEPARATOR_WINDOWS |
Constructor and Description |
---|
IOUtils() |
Modifier and Type | Method and Description |
---|---|
static File |
absolutize(File base,
String path)
Resolves the given path with respect to given base.
|
static void |
closeQuietly(InputStream input)
Deprecated.
Use Java 7
try -with-resources instead. |
static void |
closeQuietly(OutputStream output)
Deprecated.
Use Java 7
try -with-resources instead. |
static void |
closeQuietly(Reader input)
Deprecated.
Use Java 7
try -with-resources instead. |
static void |
closeQuietly(Writer output)
Deprecated.
Use Java 7
try -with-resources instead. |
static boolean |
contentEquals(InputStream input1,
InputStream input2)
Deprecated.
Use instead
IOUtils.contentEquals(java.io.InputStream, java.io.InputStream) |
static boolean |
contentEquals(Reader input1,
Reader input2)
Deprecated.
Use instead
IOUtils.contentEquals(java.io.Reader, java.io.Reader) |
static void |
copy(File src,
OutputStream out) |
static void |
copy(InputStream in,
File out) |
static int |
copy(InputStream input,
OutputStream output)
Deprecated.
Use instead
IOUtils.copy(java.io.InputStream, java.io.OutputStream) |
static void |
copy(InputStream input,
Writer output)
Deprecated.
Use instead
IOUtils.copy(java.io.InputStream, java.io.Writer) |
static void |
copy(InputStream input,
Writer output,
String encoding)
Deprecated.
Use instead
IOUtils.copy(java.io.InputStream, java.io.Writer, String) |
static void |
copy(Reader input,
OutputStream output)
Deprecated.
Use instead
IOUtils.copy(java.io.Reader, java.io.OutputStream) |
static void |
copy(Reader input,
OutputStream output,
String encoding)
Deprecated.
Use instead
IOUtils.copy(java.io.Reader, java.io.OutputStream, String) |
static int |
copy(Reader input,
Writer output)
Deprecated.
Use instead
IOUtils.copy(java.io.Reader, java.io.Writer) |
static long |
copyLarge(InputStream input,
OutputStream output)
Deprecated.
Use instead
IOUtils.copyLarge(java.io.InputStream, java.io.OutputStream) |
static long |
copyLarge(Reader input,
Writer output)
Deprecated.
Use instead
IOUtils.copyLarge(java.io.Reader, java.io.Writer) |
static void |
drain(InputStream in)
Drains the input stream and closes it.
|
static boolean |
isAbsolute(String path)
|
static org.apache.commons.io.LineIterator |
lineIterator(InputStream input,
String encoding)
Deprecated.
Use instead
IOUtils.lineIterator(java.io.InputStream, String) |
static org.apache.commons.io.LineIterator |
lineIterator(Reader reader)
Deprecated.
Use instead
IOUtils.lineIterator(java.io.Reader) |
static File |
mkdirs(File dir)
Ensures that the given directory exists (if not, it's created, including all the parent directories.)
|
static int |
mode(File f)
Gets the mode of a file/directory, if appropriate.
|
static String |
readFirstLine(InputStream is,
String encoding)
Read the first line of the given stream, close it, and return that line.
|
static List |
readLines(InputStream input)
Deprecated.
Use instead
IOUtils.readLines(java.io.InputStream) |
static List |
readLines(InputStream input,
String encoding)
Deprecated.
Use instead
IOUtils.readLines(java.io.InputStream, String) |
static List |
readLines(Reader input)
Deprecated.
Use instead
IOUtils.readLines(java.io.Reader) |
static InputStream |
skip(InputStream in,
long size)
Fully skips the specified size from the given input stream.
|
static byte[] |
toByteArray(InputStream input)
Deprecated.
Use instead
IOUtils.toByteArray(java.io.InputStream) |
static byte[] |
toByteArray(Reader input)
Deprecated.
Use instead
IOUtils.toByteArray(java.io.Reader) |
static byte[] |
toByteArray(Reader input,
String encoding)
Deprecated.
Use instead
IOUtils.toByteArray(java.io.Reader, String) |
static byte[] |
toByteArray(String input)
Deprecated.
Use instead
IOUtils.toByteArray(String) |
static char[] |
toCharArray(InputStream is)
Deprecated.
Use instead
IOUtils.toCharArray(java.io.InputStream) |
static char[] |
toCharArray(InputStream is,
String encoding)
Deprecated.
Use instead
IOUtils.toCharArray(java.io.InputStream, String) |
static char[] |
toCharArray(Reader input)
Deprecated.
Use instead
IOUtils.toCharArray(java.io.Reader) |
static InputStream |
toInputStream(String input)
Deprecated.
Use instead
IOUtils.toInputStream(String) |
static InputStream |
toInputStream(String input,
String encoding)
Deprecated.
Use instead
IOUtils.toInputStream(String, String) |
static String |
toString(byte[] input)
Deprecated.
Use instead
IOUtils.toString(byte[]) |
static String |
toString(byte[] input,
String encoding)
Deprecated.
Use instead
IOUtils.toString(byte[], String) |
static String |
toString(InputStream input)
Deprecated.
Use instead
IOUtils.toString(java.io.InputStream) |
static String |
toString(InputStream input,
String encoding)
Deprecated.
Use instead
IOUtils.toString(java.io.InputStream, String) |
static String |
toString(Reader input)
Deprecated.
Use instead
IOUtils.toString(java.io.Reader) |
static void |
write(byte[] data,
OutputStream output)
Deprecated.
Use instead
IOUtils.write(byte[], java.io.OutputStream) |
static void |
write(byte[] data,
Writer output)
Deprecated.
Use instead
IOUtils.write(byte[], java.io.Writer) |
static void |
write(byte[] data,
Writer output,
String encoding)
Deprecated.
Use instead
IOUtils.write(byte[], java.io.Writer, String) |
static void |
write(char[] data,
OutputStream output)
Deprecated.
Use instead
IOUtils.write(char[], java.io.OutputStream) |
static void |
write(char[] data,
OutputStream output,
String encoding)
Deprecated.
Use instead
IOUtils.write(char[], java.io.OutputStream, String) |
static void |
write(char[] data,
Writer output)
Deprecated.
Use instead
IOUtils.write(char[], java.io.OutputStream) |
static void |
write(StringBuffer data,
OutputStream output)
Deprecated.
Use instead
IOUtils.write(StringBuffer, java.io.OutputStream) |
static void |
write(StringBuffer data,
OutputStream output,
String encoding)
Deprecated.
Use instead
IOUtils.write(StringBuffer, java.io.OutputStream, String) |
static void |
write(StringBuffer data,
Writer output)
Deprecated.
Use instead
IOUtils.write(StringBuffer, java.io.Writer) |
static void |
write(String data,
OutputStream output)
Deprecated.
Use instead
IOUtils.write(String, java.io.OutputStream) |
static void |
write(String data,
OutputStream output,
String encoding)
Deprecated.
Use instead
IOUtils.write(String, java.io.OutputStream, String) |
static void |
write(String data,
Writer output)
Deprecated.
Use instead
IOUtils.write(char[], java.io.Writer) |
static void |
writeLines(Collection lines,
String lineEnding,
OutputStream output)
Deprecated.
Use instead
IOUtils.writeLines(java.util.Collection, String, java.io.OutputStream) |
static void |
writeLines(Collection lines,
String lineEnding,
OutputStream output,
String encoding)
Deprecated.
Use instead
IOUtils.writeLines(java.util.Collection, String, java.io.OutputStream, String) |
static void |
writeLines(Collection lines,
String lineEnding,
Writer writer)
Deprecated.
Use instead
IOUtils.writeLines(java.util.Collection, String, java.io.Writer) |
@Deprecated public static final char DIR_SEPARATOR_UNIX
IOUtils.DIR_SEPARATOR_UNIX
@Deprecated public static final char DIR_SEPARATOR_WINDOWS
IOUtils.DIR_SEPARATOR_WINDOWS
@Deprecated public static final char DIR_SEPARATOR
IOUtils.DIR_SEPARATOR
@Deprecated public static final String LINE_SEPARATOR_UNIX
IOUtils.LINE_SEPARATOR_UNIX
@Deprecated public static final String LINE_SEPARATOR_WINDOWS
IOUtils.LINE_SEPARATOR_WINDOWS
@Deprecated public static final String LINE_SEPARATOR
IOUtils.LINE_SEPARATOR
public static void drain(InputStream in) throws IOException
IOException
public static void copy(File src, OutputStream out) throws IOException
IOException
public static void copy(InputStream in, File out) throws IOException
IOException
public static File mkdirs(File dir) throws IOException
IOException
public static InputStream skip(InputStream in, long size) throws IOException
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 as FileInputStream.skip(long)
returning -1.
So to reliably skip just the N bytes, we'll actually read all those bytes.
IOException
public static File absolutize(File base, String path)
It would be nice if File#File(File, String) were doing this.
base
- File that represents the parent, may be null if path is absolutepath
- Path of the file, may not be nullFilePath.absolutize()
public static boolean isAbsolute(String path)
path
- String representing Platform Specific
(unlike FilePath, which may get Platform agnostic paths), may not be nullpublic static int mode(File f) throws PosixException
Files.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.
PosixException
- if the file could not be statted, e.g. broken symlinkpublic static String readFirstLine(InputStream is, String encoding) throws IOException
encoding
- If null, use the platform default encoding.IOException
@Deprecated public static void closeQuietly(Reader input)
try
-with-resources instead.@Deprecated public static void closeQuietly(Writer output)
try
-with-resources instead.@Deprecated public static void closeQuietly(InputStream input)
try
-with-resources instead.@Deprecated public static void closeQuietly(OutputStream output)
try
-with-resources instead.@Deprecated public static byte[] toByteArray(InputStream input) throws IOException
IOUtils.toByteArray(java.io.InputStream)
IOException
@Deprecated public static byte[] toByteArray(Reader input) throws IOException
IOUtils.toByteArray(java.io.Reader)
IOException
@Deprecated public static byte[] toByteArray(Reader input, String encoding) throws IOException
IOUtils.toByteArray(java.io.Reader, String)
IOException
@Deprecated public static byte[] toByteArray(String input) throws IOException
IOUtils.toByteArray(String)
IOException
@Deprecated public static char[] toCharArray(InputStream is) throws IOException
IOUtils.toCharArray(java.io.InputStream)
IOException
@Deprecated public static char[] toCharArray(InputStream is, String encoding) throws IOException
IOUtils.toCharArray(java.io.InputStream, String)
IOException
@Deprecated public static char[] toCharArray(Reader input) throws IOException
IOUtils.toCharArray(java.io.Reader)
IOException
@Deprecated public static String toString(InputStream input) throws IOException
IOUtils.toString(java.io.InputStream)
IOException
@Deprecated public static String toString(InputStream input, String encoding) throws IOException
IOUtils.toString(java.io.InputStream, String)
IOException
@Deprecated public static String toString(Reader input) throws IOException
IOUtils.toString(java.io.Reader)
IOException
@Deprecated public static String toString(byte[] input) throws IOException
IOUtils.toString(byte[])
IOException
@Deprecated public static String toString(byte[] input, String encoding) throws IOException
IOUtils.toString(byte[], String)
IOException
@Deprecated public static List readLines(InputStream input) throws IOException
IOUtils.readLines(java.io.InputStream)
IOException
@Deprecated public static List readLines(InputStream input, String encoding) throws IOException
IOUtils.readLines(java.io.InputStream, String)
IOException
@Deprecated public static List readLines(Reader input) throws IOException
IOUtils.readLines(java.io.Reader)
IOException
@Deprecated public static org.apache.commons.io.LineIterator lineIterator(Reader reader)
IOUtils.lineIterator(java.io.Reader)
@Deprecated public static org.apache.commons.io.LineIterator lineIterator(InputStream input, String encoding) throws IOException
IOUtils.lineIterator(java.io.InputStream, String)
IOException
@Deprecated public static InputStream toInputStream(String input)
IOUtils.toInputStream(String)
@Deprecated public static InputStream toInputStream(String input, String encoding) throws IOException
IOUtils.toInputStream(String, String)
IOException
@Deprecated public static void write(byte[] data, OutputStream output) throws IOException
IOUtils.write(byte[], java.io.OutputStream)
IOException
@Deprecated public static void write(byte[] data, Writer output) throws IOException
IOUtils.write(byte[], java.io.Writer)
IOException
@Deprecated public static void write(byte[] data, Writer output, String encoding) throws IOException
IOUtils.write(byte[], java.io.Writer, String)
IOException
@Deprecated public static void write(char[] data, Writer output) throws IOException
IOUtils.write(char[], java.io.OutputStream)
IOException
@Deprecated public static void write(char[] data, OutputStream output) throws IOException
IOUtils.write(char[], java.io.OutputStream)
IOException
@Deprecated public static void write(char[] data, OutputStream output, String encoding) throws IOException
IOUtils.write(char[], java.io.OutputStream, String)
IOException
@Deprecated public static void write(String data, Writer output) throws IOException
IOUtils.write(char[], java.io.Writer)
IOException
@Deprecated public static void write(String data, OutputStream output) throws IOException
IOUtils.write(String, java.io.OutputStream)
IOException
@Deprecated public static void write(String data, OutputStream output, String encoding) throws IOException
IOUtils.write(String, java.io.OutputStream, String)
IOException
@Deprecated public static void write(StringBuffer data, Writer output) throws IOException
IOUtils.write(StringBuffer, java.io.Writer)
IOException
@Deprecated public static void write(StringBuffer data, OutputStream output) throws IOException
IOUtils.write(StringBuffer, java.io.OutputStream)
IOException
@Deprecated public static void write(StringBuffer data, OutputStream output, String encoding) throws IOException
IOUtils.write(StringBuffer, java.io.OutputStream, String)
IOException
@Deprecated public static void writeLines(Collection lines, String lineEnding, OutputStream output) throws IOException
IOUtils.writeLines(java.util.Collection, String, java.io.OutputStream)
IOException
@Deprecated public static void writeLines(Collection lines, String lineEnding, OutputStream output, String encoding) throws IOException
IOUtils.writeLines(java.util.Collection, String, java.io.OutputStream, String)
IOException
@Deprecated public static void writeLines(Collection lines, String lineEnding, Writer writer) throws IOException
IOUtils.writeLines(java.util.Collection, String, java.io.Writer)
IOException
@Deprecated public static int copy(InputStream input, OutputStream output) throws IOException
IOUtils.copy(java.io.InputStream, java.io.OutputStream)
IOException
@Deprecated public static long copyLarge(InputStream input, OutputStream output) throws IOException
IOUtils.copyLarge(java.io.InputStream, java.io.OutputStream)
IOException
@Deprecated public static void copy(InputStream input, Writer output) throws IOException
IOUtils.copy(java.io.InputStream, java.io.Writer)
IOException
@Deprecated public static void copy(InputStream input, Writer output, String encoding) throws IOException
IOUtils.copy(java.io.InputStream, java.io.Writer, String)
IOException
@Deprecated public static int copy(Reader input, Writer output) throws IOException
IOUtils.copy(java.io.Reader, java.io.Writer)
IOException
@Deprecated public static long copyLarge(Reader input, Writer output) throws IOException
IOUtils.copyLarge(java.io.Reader, java.io.Writer)
IOException
@Deprecated public static void copy(Reader input, OutputStream output) throws IOException
IOUtils.copy(java.io.Reader, java.io.OutputStream)
IOException
@Deprecated public static void copy(Reader input, OutputStream output, String encoding) throws IOException
IOUtils.copy(java.io.Reader, java.io.OutputStream, String)
IOException
@Deprecated public static boolean contentEquals(InputStream input1, InputStream input2) throws IOException
IOUtils.contentEquals(java.io.InputStream, java.io.InputStream)
IOException
@Deprecated public static boolean contentEquals(Reader input1, Reader input2) throws IOException
IOUtils.contentEquals(java.io.Reader, java.io.Reader)
IOException
Copyright © 2004–2021. All rights reserved.