summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/openslx/taskmanager/tasks/DownloadText.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main/java/org/openslx/taskmanager/tasks/DownloadText.java b/src/main/java/org/openslx/taskmanager/tasks/DownloadText.java
index b62dc12..db0b126 100644
--- a/src/main/java/org/openslx/taskmanager/tasks/DownloadText.java
+++ b/src/main/java/org/openslx/taskmanager/tasks/DownloadText.java
@@ -1,6 +1,7 @@
package org.openslx.taskmanager.tasks;
import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
@@ -49,19 +50,19 @@ public class DownloadText extends AbstractTask
status.error = "Remote file too large: " + status.size + " bytes!";
return false;
}
- StringBuilder sb = new StringBuilder( Math.max( 8, status.size ) );
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream( Math.max( 512, status.size ) );
final byte data[] = new byte[ 9000 ];
int count;
while ( ( count = in.read( data, 0, data.length ) ) != -1 ) {
- sb.append( new String( data, 0, count, StandardCharsets.UTF_8 ) );
+ baos.write( data, 0, count );
status.complete += count;
if ( status.complete > MAX_SIZE ) {
status.error = "Remote file too large: > " + status.complete + " bytes!";
return false;
}
}
- status.content = sb.toString();
+ status.content = new String( baos.toByteArray(), StandardCharsets.UTF_8 );
return true;
} catch ( IOException e ) {
status.error = "Download error: " + e.toString();