org.springframework.batch.item.util

## Class FileUtils

- java.lang.Object
- - org.springframework.batch.item.util.FileUtils

-     public final class FileUtils
      extends java.lang.Object

  Utility methods for files used in batch processing.
  Author:
    Peter Zozom

- - ### Method Summary

    All Methods Static Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `createNewFile(java.io.File file)` Create a new file if it doesn't already exist.
    `static void` | `setUpOutputFile(java.io.File file, boolean restarted, boolean overwriteOutputFile)` Deprecated. use the version with explicit append parameter instead. Here append=false is assumed.
    `static void` | `setUpOutputFile(java.io.File file, boolean restarted, boolean append, boolean overwriteOutputFile)` Set up output file for batch processing.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### setUpOutputFile

          public static void setUpOutputFile(java.io.File file,
                                             boolean restarted,
                                             boolean append,
                                             boolean overwriteOutputFile)

      Set up output file for batch processing. This method implements common logic for handling output files when starting or restarting file I/O. When starting output file processing, creates/overwrites new file. When restarting output file processing, checks whether file is writable.
      Parameters:
        `file` - file to be set up
        `restarted` - true signals that we are restarting output file processing
        `append` - true signals input file may already exist (but doesn't have to)
        `overwriteOutputFile` - If set to true, output file will be overwritten (this flag is ignored when processing is restart)

    - #### setUpOutputFile

          @Deprecated
          public static void setUpOutputFile(java.io.File file,
                                                         boolean restarted,
                                                         boolean overwriteOutputFile)

      Deprecated. use the version with explicit append parameter instead. Here append=false is assumed.
      Set up output file for batch processing. This method implements common logic for handling output files when starting or restarting file I/O. When starting output file processing, creates/overwrites new file. When restarting output file processing, checks whether file is writable.
      Parameters:
        `file` - file to be set up
        `restarted` - true signals that we are restarting output file processing
        `overwriteOutputFile` - If set to true, output file will be overwritten (this flag is ignored when processing is restart)
      Throws:
        `java.lang.IllegalArgumentException` - when file is null
        `ItemStreamException` - when starting output file processing, file exists and flag "overwriteOutputFile" is set to false
        `ItemStreamException` - when unable to create file or file is not writable

    - #### createNewFile

          public static boolean createNewFile(java.io.File file)
                                       throws java.io.IOException

      Create a new file if it doesn't already exist.
      Parameters:
        `file` - the file to create on the filesystem
      Returns:
        true if file was created else false.
      Throws:
        `java.io.IOException` - is thrown if error occurs during creation and file does not exist.