Package migratedb.core.internal.util
Enum FileCopyUtils
- java.lang.Object
-
- java.lang.Enum<FileCopyUtils>
-
- migratedb.core.internal.util.FileCopyUtils
-
- All Implemented Interfaces:
Serializable,Comparable<FileCopyUtils>
public enum FileCopyUtils extends Enum<FileCopyUtils>
Utility class for copying files and their contents. Inspired by Spring's own.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcopy(InputStream in, OutputStream out)Copy the contents of the given InputStream to the given OutputStream.static voidcopy(Reader in, Writer out)Copy the contents of the given Reader to the given Writer.static byte[]copyToByteArray(InputStream in)Copy the contents of the given InputStream into a new byte array.static StringcopyToString(InputStream in, Charset encoding)Copy the contents of the given InputStream into a new String based on this encoding.static StringcopyToString(Reader in)Copy the contents of the given Reader into a String.static FileCopyUtilsvalueOf(String name)Returns the enum constant of this type with the specified name.static FileCopyUtils[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Method Detail
-
values
public static FileCopyUtils[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (FileCopyUtils c : FileCopyUtils.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static FileCopyUtils valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
copyToString
public static String copyToString(Reader in) throws IOException
Copy the contents of the given Reader into a String. Closes the reader when done.- Parameters:
in- the reader to copy from- Returns:
- the String that has been copied to
- Throws:
IOException- in case of I/O errors
-
copyToByteArray
public static byte[] copyToByteArray(InputStream in) throws IOException
Copy the contents of the given InputStream into a new byte array. Closes the stream when done.- Parameters:
in- the stream to copy from- Returns:
- the new byte array that has been copied to
- Throws:
IOException- in case of I/O errors
-
copyToString
public static String copyToString(InputStream in, Charset encoding) throws IOException
Copy the contents of the given InputStream into a new String based on this encoding. Closes the stream when done.- Parameters:
in- the stream to copy fromencoding- The encoding to use.- Returns:
- The new String.
- Throws:
IOException- in case of I/O errors
-
copy
public static void copy(Reader in, Writer out) throws IOException
Copy the contents of the given Reader to the given Writer. Closes both when done.- Parameters:
in- the Reader to copy fromout- the Writer to copy to- Throws:
IOException- in case of I/O errors
-
copy
public static int copy(InputStream in, OutputStream out) throws IOException
Copy the contents of the given InputStream to the given OutputStream. Closes both streams when done.- Parameters:
in- the stream to copy fromout- the stream to copy to- Returns:
- the number of bytes copied
- Throws:
IOException- in case of I/O errors
-
-