/** * Writes out a string followed by a "new line", where the format of the new * line separator is determined by the underlying operating system. * * @param items list of items to be written to output stream * @throws Exception if an error occurs while writing items to the output stream */ @Override public void write(List<? extends T> items) throws Exception { if (!getOutputState().isInitialized()) { throw new WriterNotOpenException("Writer must be open before it can be written to"); } if (logger.isDebugEnabled()) { logger.debug("Writing to file with " + items.size() + " items."); } OutputState state = getOutputState(); String lines = doWrite(items); try { state.write(lines); } catch (IOException e) { throw new WriteFailedException("Could not write data. The file may be corrupt.", e); } state.setLinesWritten(state.getLinesWritten() + items.size()); }
/** * Initialize the reader. This method may be called multiple times before * close is called. * * @see ItemStream#open(ExecutionContext) */ @Override public void open(ExecutionContext executionContext) throws ItemStreamException { super.open(executionContext); Assert.notNull(resource, "The resource must be set"); if (!getOutputState().isInitialized()) { doOpen(executionContext); } }
/** * Writes out a string followed by a "new line", where the format of the new * line separator is determined by the underlying operating system. * * @param items list of items to be written to output stream * @throws Exception if an error occurs while writing items to the output stream */ @Override public void write(List<? extends T> items) throws Exception { if (!getOutputState().isInitialized()) { throw new WriterNotOpenException("Writer must be open before it can be written to"); } if (logger.isDebugEnabled()) { logger.debug("Writing to file with " + items.size() + " items."); } OutputState state = getOutputState(); String lines = doWrite(items); try { state.write(lines); } catch (IOException e) { throw new WriteFailedException("Could not write data. The file may be corrupt.", e); } state.setLinesWritten(state.getLinesWritten() + items.size()); }
/** * Initialize the reader. This method may be called multiple times before * close is called. * * @see ItemStream#open(ExecutionContext) */ @Override public void open(ExecutionContext executionContext) throws ItemStreamException { super.open(executionContext); Assert.notNull(resource, "The resource must be set"); if (!getOutputState().isInitialized()) { doOpen(executionContext); } }