public static void transfer(FileChannel inputChannel, ByteChannel outputChannel,
long lengthInBytes, long chunckSizeInBytes, boolean verbose) throws IOException
{
progMonitor = new ProgressMonitor(null, "Kopiere " + src.getName(), "Kopiert... ", 0, 100);
long overallBytesTransfered = 0L;
while (overallBytesTransfered < lengthInBytes && verbose)
{
long bytesToTransfer = Math.min(chunckSizeInBytes, lengthInBytes - overallBytesTransfered);
long bytesTransfered = inputChannel.transferTo(overallBytesTransfered, bytesToTransfer,
outputChannel);
overallBytesTransfered += bytesTransfered;
double megabyte = overallBytesTransfered / 1048576;
if (verbose && progMonitor != null)
{
long percentageOfOverallBytesTransfered = Math.round(overallBytesTransfered / ((double) lengthInBytes) * 100.0);
progMonitor.setNote("<html>Fortschritt: " + percentageOfOverallBytesTransfered + " %<br>"
+ "MB übertragen: " + megabyte);
progMonitor.setProgress((int) percentageOfOverallBytesTransfered);
// createlogfile("overall bytes transfered: " +
// overallBytesTransfered +
// "\tPercent transferred " + percentageOfOverallBytesTransfered + "%");
}
}
if (progMonitor != null)
{
progMonitor.close();
}
progMonitor = null;
}