Package com.cedarsoftware.util
Interface IOUtilities.TransferCallback
- Enclosing class:
- IOUtilities
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Callback interface for monitoring and controlling byte transfers.
The callback receives a defensive copy of the transfer buffer to ensure thread safety and prevent race conditions. Implementations can safely modify the provided buffer without affecting the ongoing transfer operation.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
bytesTransferred
(byte[] bytes, int count) Called when bytes are transferred during an operation.default boolean
Checks if the transfer operation should be cancelled.
-
Method Details
-
bytesTransferred
void bytesTransferred(byte[] bytes, int count) Called when bytes are transferred during an operation.The provided buffer is a defensive copy containing only the transferred bytes. It is safe to modify this buffer without affecting the transfer operation.
- Parameters:
bytes
- the buffer containing the transferred bytes (defensive copy)count
- the number of bytes actually transferred (equals bytes.length)
-
isCancelled
default boolean isCancelled()Checks if the transfer operation should be cancelled. Default implementation returns false.- Returns:
- true if the transfer should be cancelled, false to continue
-