Class SlicedTransferFileHandler


  • public class SlicedTransferFileHandler
    extends Object
    Takes part in sliced transfer, making sure that: 1) The local file writer is created lazilly, only when we start downloading a slice belonging to the file 2) The local file's writer is closed immediately after writing the last slice of the file
    Author:
    Eyal Schneider
    • Constructor Detail

      • SlicedTransferFileHandler

        public SlicedTransferFileHandler​(File file,
                                         int fileSliceCount)
        Constructor
        Parameters:
        file - The local file we are writing to
        fileSliceCount - The total number of slices to be written to the file
    • Method Detail

      • getWriter

        public FileChannel getWriter()
                              throws IOException
        Returns:
        The writer to be used for writing to the local file. Created lazilly.
        Throws:
        IOException - In case the file can't be created
      • doneSliceProcessing

        public void doneSliceProcessing()
                                 throws IOException
        Call this method each time a slice download for this file is complete. Once the method detects all slices are complete, the file is closed
        Throws:
        IOException - In case the file can't be closed