// }
result.setName(targetFileName);
result.setSize(source.getSize());
- OutputStream outputStream = outputLister.getOutputStream(result);
- if (outputStream == null)
- throw new Exception("OutputStream is null!");
ProgressEvent progressEvent = new ProgressEvent(this, 0);
StatusEvent statusEvent = new StatusEvent(this);
long size = source.getSize();
BufferedInputStream in = new BufferedInputStream(inputStream, BUFFER_SIZE);
- BufferedOutputStream out = new BufferedOutputStream(outputStream, BUFFER_SIZE);
+ OutputStream outputStream = null;
+ BufferedOutputStream out = null;
try {
int lastPercent = 0;
while ((byteCount = in.read(buffer, 0, BUFFER_SIZE)) != -1) {
+ if (out == null) {
+ outputStream = outputLister.getOutputStream(result);
+ if (outputStream == null)
+ throw new Exception("OutputStream is null!");
+ out = new BufferedOutputStream(outputStream, BUFFER_SIZE);
+ }
+
out.write(buffer, 0, byteCount);
uploadedBytes += byteCount;