Class TransferUtil

java.lang.Object
com.vaadin.flow.server.streams.TransferUtil

public final class TransferUtil extends Object
Utility class with methods for handling transfer of upload and download requests.
  • Field Details

    • DEFAULT_BUFFER_SIZE

      public static int DEFAULT_BUFFER_SIZE
      Default buffer size for reading data from the input stream.

      Follows the default buffer size of the Java InputStream.transferTo(OutputStream).

  • Constructor Details

    • TransferUtil

      public TransferUtil()
  • Method Details

    • transfer

      public static long transfer(InputStream inputStream, OutputStream outputStream, TransferContext transferContext, Collection<TransferProgressListener> listeners) throws IOException
      Transfers data from the given input stream to the output stream while notifying the progress to the given listeners.
      Parameters:
      inputStream - the input stream to read from
      outputStream - the output stream to write to
      transferContext - the transfer request containing metadata about the transfer
      listeners - collection of listeners to notify about progress
      Returns:
      the number of bytes transferred
      Throws:
      IOException - if an I/O error occurs during the transfer