Package org.springframework.batch.item.support

# Class AbstractFileItemWriter.OutputState

java.lang.Object
org.springframework.batch.item.support.AbstractFileItemWriter.OutputState

Enclosing class:
  AbstractFileItemWriter<T>

protected class AbstractFileItemWriter.OutputState extends Object
Encapsulates the runtime state of the writer. All state changing operations on the writer go through this class.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `OutputState()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Close the open resource and reset counters.
  `long`
  `getLinesWritten()`
  `boolean`
  `isInitialized()`
  `long`
  `position()`
  Return the byte offset position of the cursor in the output file as a long integer.
  `void`
  `restoreFrom(ExecutionContext executionContext)`
  `void`
  `setAppendAllowed(boolean append)`
  `void`
  `setDeleteIfExists(boolean shouldDeleteIfExists)`
  `void`
  `setEncoding(String encoding)`
  `void`
  `setLinesWritten(long linesWritten)`
  `void`
  `truncate()`
  Truncate the output at the last known good point.
  `void`
  `write(String line)`

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

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

- ## Constructor Details

  - ### OutputState

    protected OutputState()

- ## Method Details

  - ### position

    public long position() throws IOException
    Return the byte offset position of the cursor in the output file as a long integer.
    Returns:
      the byte offset position of the cursor in the output file
    Throws:
      `IOException` - If unable to get the offset position

  - ### setAppendAllowed

    public void setAppendAllowed(boolean append)
    Parameters:
      `append` - if true, append to previously created file

  - ### restoreFrom

    public void restoreFrom(ExecutionContext executionContext)
    Parameters:
      `executionContext` - state from which to restore writing from

  - ### setDeleteIfExists

    public void setDeleteIfExists(boolean shouldDeleteIfExists)
    Parameters:
      `shouldDeleteIfExists` - indicator

  - ### setEncoding

    public void setEncoding(String encoding)
    Parameters:
      `encoding` - file encoding

  - ### getLinesWritten

    public long getLinesWritten()

  - ### setLinesWritten

    public void setLinesWritten(long linesWritten)

  - ### close

    public void close()
    Close the open resource and reset counters.

  - ### write

    public void write(String line) throws IOException
    Parameters:
      `line` - String to be written to the file
    Throws:
      `IOException` - If unable to write the String to the file

  - ### truncate

    public void truncate() throws IOException
    Truncate the output at the last known good point.
    Throws:
      `IOException` - if unable to work with file

  - ### isInitialized

    public boolean isInitialized()