Class AbstractFileItemWriter.OutputState
java.lang.Object
org.springframework.batch.item.support.AbstractFileItemWriter.OutputState
- Enclosing class:
- AbstractFileItemWriter<T>
Encapsulates the runtime state of the writer. All state changing operations on the
writer go through this class.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the open resource and reset counters.longbooleanlongposition()Return the byte offset position of the cursor in the output file as a long integer.voidrestoreFrom(ExecutionContext executionContext) voidsetAppendAllowed(boolean append) voidsetDeleteIfExists(boolean shouldDeleteIfExists) voidsetEncoding(String encoding) voidsetLinesWritten(long linesWritten) voidtruncate()Truncate the output at the last known good point.void
-
Constructor Details
-
OutputState
protected OutputState()
-
-
Method Details
-
position
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
- Parameters:
executionContext- state from which to restore writing from
-
setDeleteIfExists
public void setDeleteIfExists(boolean shouldDeleteIfExists) - Parameters:
shouldDeleteIfExists- indicator
-
setEncoding
- 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
- Parameters:
line- String to be written to the file- Throws:
IOException- If unable to write the String to the file
-
truncate
Truncate the output at the last known good point.- Throws:
IOException- if unable to work with file
-
isInitialized
public boolean isInitialized()
-