SpringIOUtils (Grails 6.0.0)

Package: org.grails.io.support

## [Java] Class SpringIOUtils

- org.grails.io.support.SpringIOUtils

-     @java.lang.SuppressWarnings("unchecked")
      public class SpringIOUtils
      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
    Graeme Rocher
  Since:
    06.10.2003

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static int` | `BUFFER_SIZE` |
    `private static char[]` | `CHARS` |
    `private static java.util.Map` | `algorithms` |
    `private static javax.xml.parsers.SAXParserFactory` | `saxParserFactory` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static java.lang.Object[]` | `addAll(java.lang.Object[] array1, java.lang.Object[] array2)` Adds the contents of 1 array to another
    `` | `public static java.lang.String` | `byteArrayToHexString(byte[] in)` Convert a byte[] array to readable string format.
    `` | `public static void` | `closeQuietly(java.io.Closeable closeable)` Closes a closeable gracefully without throwing exceptions etc.
    `` | `private static byte[]` | `compute(java.io.File f, java.lang.String algorithm)`
    `` | `public static java.lang.String` | `computeChecksum(java.io.File f, java.lang.String algorithm)`
    `` | `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.
    `` | `public static int` | `copy(Resource in, java.io.File out)` Copy the contents of the given input File to the given output File.
    `` | `public static void` | `copy(byte[] in, java.io.File out)` Copy the contents of the given byte array to the given output File.
    `` | `public static int` | `copy(java.io.InputStream in, java.io.OutputStream out)` Copy the contents of the given InputStream to the given OutputStream.
    `` | `public static void` | `copy(byte[] in, java.io.OutputStream out)` Copy the contents of the given byte array to the given OutputStream.
    `` | `public static int` | `copy(java.io.Reader in, java.io.Writer out)` Copy the contents of the given Reader to the given Writer.
    `` | `public static void` | `copy(java.lang.String in, java.io.Writer out)` Copy the contents of the given String to the given output Writer.
    `` | `public static void` | `copyAll(Resource base, org.springframework.core.io.Resource[] resources, java.io.File targetDir)` Copies all the resources for the given target directory.
    `` | `public static byte[]` | `copyToByteArray(java.io.File in)` Copy the contents of the given input File into a new byte array.
    `` | `public static byte[]` | `copyToByteArray(java.io.InputStream in)` Copy the contents of the given InputStream into a new byte array.
    `` | `public static java.lang.String` | `copyToString(java.io.Reader in)` Copy the contents of the given Reader into a String.
    `` | `private static javax.xml.parsers.SAXParserFactory` | `createParserFactory()`
    `` | `public static groovy.util.XmlSlurper` | `createXmlSlurper()`
    `` | `private static java.security.MessageDigest` | `getMessageDigest(java.lang.String algorithm)`
    `` | `public static javax.xml.parsers.SAXParser` | `newSAXParser()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), 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

    - #### public static final int BUFFER_SIZE

    - #### private static final char[] CHARS

    - #### @java.lang.SuppressWarnings("rawtypes") private static java.util.Map algorithms

    - #### private static javax.xml.parsers.SAXParserFactory saxParserFactory

  - ### Method Detail

    - #### 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

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

      Convert a byte[] array to readable string format. This makes the "hex" readable!

      Returns:
        result String buffer in String format
      Parameters:
        `in` - byte[] buffer to convert to string format

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

      Closes a closeable gracefully without throwing exceptions etc.

      Parameters:
        `closeable` - The closeable

    - #### private static byte[] compute(java.io.File f, java.lang.String algorithm)

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

    - #### 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

    - #### public static int copy(Resource 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

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

      Copy the contents of the given byte array to the given output File.

      throws:
        IOException in case of I/O errors
      Parameters:
        `in` - the byte array to copy from
        `out` - the file to copy to

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

      Copy the contents of the given InputStream to the given OutputStream. Closes both streams when done.

      throws:
        IOException in case of I/O errors
      Parameters:
        `in` - the stream to copy from
        `out` - the stream to copy to
      Returns:
        the number of bytes copied

    - #### 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

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

      Copy the contents of the given Reader to the given Writer. Closes both when done.

      throws:
        IOException in case of I/O errors
      Parameters:
        `in` - the Reader to copy from
        `out` - the Writer to copy to
      Returns:
        the number of characters copied

    - #### 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

    - #### public static void copyAll(Resource base, org.springframework.core.io.Resource[] resources, java.io.File targetDir)

      Copies all the resources for the given target directory. The base resource serves to calculate the relative path such that the directory structure is maintained

      Parameters:
        `base` - The base resource
        `resources` - The resources to copy
        `targetDir` - The target directory

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

      Copy the contents of the given input File into a new byte array.

      throws:
        IOException in case of I/O errors
      Parameters:
        `in` - the file to copy from
      Returns:
        the new byte array that has been copied to

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

      Copy the contents of the given InputStream into a new byte array. Closes the stream when done.

      throws:
        IOException in case of I/O errors
      Parameters:
        `in` - the stream to copy from
      Returns:
        the new byte array that has been copied to

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

      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

    - #### private static javax.xml.parsers.SAXParserFactory createParserFactory()

    - #### public static groovy.util.XmlSlurper createXmlSlurper()

    - #### private static java.security.MessageDigest getMessageDigest(java.lang.String algorithm)

    - #### public static javax.xml.parsers.SAXParser newSAXParser()