Class FileRecordWriter

  • All Implemented Interfaces:
    RecordWriter<java.lang.String>

    public class FileRecordWriter
    extends java.lang.Object
    implements RecordWriter<java.lang.String>
    A writer that writes records to a file.
    Author:
    Mahmoud Ben Hassine ([email protected])
    • Constructor Detail

      • FileRecordWriter

        public FileRecordWriter​(java.nio.file.Path path)
        Create a new FileRecordWriter.
        Parameters:
        path - the output file.
    • Method Detail

      • setCharset

        public void setCharset​(java.nio.charset.Charset charset)
        Set the charset of the input file
        Parameters:
        charset - of the input file
      • setLineSeparator

        public void setLineSeparator​(java.lang.String lineSeparator)
        Set the line separator
        Parameters:
        lineSeparator - to use
      • setHeaderCallback

        public void setHeaderCallback​(FileRecordWriter.HeaderCallback headerCallback)
        Set a header callback.
        Parameters:
        headerCallback - to set
      • setFooterCallback

        public void setFooterCallback​(FileRecordWriter.FooterCallback footerCallback)
        Set a footer callback.
        Parameters:
        footerCallback - to set
      • setAppend

        public void setAppend​(boolean append)
        Parameter to open the writer in append mode.
        Parameters:
        append - true if the writer should be opened in append mode.
      • open

        public void open()
                  throws java.lang.Exception
        Description copied from interface: RecordWriter
        Open the writer.
        Specified by:
        open in interface RecordWriter<java.lang.String>
        Throws:
        java.lang.Exception - if an error occurs during opening the writer
      • writeRecords

        public void writeRecords​(Batch<java.lang.String> batch)
                          throws java.lang.Exception
        Description copied from interface: RecordWriter
        Write a batch of records to a data sink.
        Specified by:
        writeRecords in interface RecordWriter<java.lang.String>
        Parameters:
        batch - of records to write.
        Throws:
        java.lang.Exception - if an error occurs during record writing
      • close

        public void close()
                   throws java.lang.Exception
        Description copied from interface: RecordWriter
        Close the writer
        Specified by:
        close in interface RecordWriter<java.lang.String>
        Throws:
        java.lang.Exception - if an error occurs during closing the writer