IOUtils (Grails 2.3.8)
Date: 2014-04-24

Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.grails.io.support
[Java] Class IOUtils

    java.lang.Object
      org.codehaus.groovy.grails.io.support.IOUtils

    @java.lang.SuppressWarnings("unchecked")
    public class IOUtils
    extends java.lang.Object

Simple utility methods for file and stream copying. All copy methods use a block size of 4096 bytes, and close all affected streams when done.

Mainly for use within the framework, but also useful for application code.

Authors:
  Juergen Hoeller

Since:
  06.10.2003

Field Summary
`static int` | `BUFFER_SIZE`

Method Summary
`static java.lang.Object[]` | `addAll(java.lang.Object[] array1, java.lang.Object[] array2)` Adds the contents of 1 array to another
`static java.lang.String` | `byteArrayToHexString(byte[] in)` Convert a byte[] array to readable string format.
`static void` | `closeQuietly(java.io.Closeable closeable)` Copy the contents of the given Reader into a String.
`static java.lang.String` | `computeChecksum(java.io.File f, java.lang.String algorithm)`
`static int` | `copy(java.io.File in, java.io.File out)` Copy the contents of the given input File to the given output File.
`static void` | `copy(byte[] in, java.io.File out)`
`static int` | `copy(java.io.InputStream in, java.io.OutputStream out)`
`static void` | `copy(byte[] in, java.io.OutputStream out)` Copy the contents of the given byte array to the given OutputStream.
`static int` | `copy(java.io.Reader in, java.io.Writer out)`
`static void` | `copy(java.lang.String in, java.io.Writer out)` Copy the contents of the given String to the given output Writer.
`static byte[]` | `copyToByteArray(java.io.File in)`
`static byte[]` | `copyToByteArray(java.io.InputStream in)`
`static java.lang.String` | `copyToString(java.io.Reader in)`
`static groovy.util.XmlSlurper` | `createXmlSlurper()`

Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Field Detail

### BUFFER_SIZE

    public static final int BUFFER_SIZE

Method Detail

### addAll

    public static java.lang.Object[] addAll(java.lang.Object[] array1, java.lang.Object[] array2)

  Adds the contents of 1 array to another
  Parameters:
    `array1` - The target array
    `array2` - The source array
  Returns:
    The new array

### byteArrayToHexString

    public static java.lang.String byteArrayToHexString(byte[] in)

  Convert a byte[] array to readable string format. This makes the "hex" readable!
  Parameters:
    `in` - byte[] buffer to convert to string format
  Returns:
    result String buffer in String format

### closeQuietly

    public static void closeQuietly(java.io.Closeable closeable)

  Copy the contents of the given Reader into a String. Closes the reader when done.
  throws:
    IOException in case of I/O errors
  Parameters:
    `in` - the reader to copy from
  Returns:
    the String that has been copied to

### computeChecksum

    public static java.lang.String computeChecksum(java.io.File f, java.lang.String algorithm)

### copy

    public static int copy(java.io.File in, java.io.File out)

  Copy the contents of the given input File to the given output File.
  throws:
    java.io.IOException in case of I/O errors
  Parameters:
    `in` - the file to copy from
    `out` - the file to copy to
  Returns:
    the number of bytes copied

### copy

    public static void copy(byte[] in, java.io.File out)

### copy

    public static int copy(java.io.InputStream in, java.io.OutputStream out)

### copy

    public static void copy(byte[] in, java.io.OutputStream out)

  Copy the contents of the given byte array to the given OutputStream. Closes the stream when done.
  throws:
    IOException in case of I/O errors
  Parameters:
    `in` - the byte array to copy from
    `out` - the OutputStream to copy to

### copy

    public static int copy(java.io.Reader in, java.io.Writer out)

### copy

    public static void copy(java.lang.String in, java.io.Writer out)

  Copy the contents of the given String to the given output Writer. Closes the write when done.
  throws:
    IOException in case of I/O errors
  Parameters:
    `in` - the String to copy from
    `out` - the Writer to copy to

### copyToByteArray

    public static byte[] copyToByteArray(java.io.File in)

### copyToByteArray

    public static byte[] copyToByteArray(java.io.InputStream in)

### copyToString

    public static java.lang.String copyToString(java.io.Reader in)

### createXmlSlurper

    public static groovy.util.XmlSlurper createXmlSlurper()

Groovy Documentation