Util: set buffer size to 4096

This commit is contained in:
Bixilon 2020-10-23 19:32:31 +02:00
parent 5315681395
commit 16ef8d7b06
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 5 additions and 6 deletions

View File

@ -196,7 +196,7 @@ public class AssetsManager {
// ToDo: use input steam twice ? // ToDo: use input steam twice ?
ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream(); ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream();
int len; int len;
byte[] buffer = new byte[2048]; byte[] buffer = new byte[4096];
while ((len = versionJar.read(buffer)) > 0) { while ((len = versionJar.read(buffer)) > 0) {
outputBuffer.write(buffer, 0, len); outputBuffer.write(buffer, 0, len);
} }

View File

@ -78,7 +78,7 @@ public class StartProgressWindow extends Application {
} }
@Override @Override
public void start(Stage stage) throws Exception { public void start(Stage stage) {
toolkitLatch.countDown(); toolkitLatch.countDown();
} }
} }

View File

@ -88,7 +88,7 @@ public final class Util {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
int res = 0; int res = 0;
byte[] buf = new byte[1024]; byte[] buf = new byte[4096];
while (res >= 0) { while (res >= 0) {
res = gzipInputStream.read(buf, 0, buf.length); res = gzipInputStream.read(buf, 0, buf.length);
if (res > 0) { if (res > 0) {
@ -209,11 +209,10 @@ public final class Util {
copyFile(getInputStreamByURL(url), new GZIPOutputStream(new FileOutputStream(destination))); copyFile(getInputStreamByURL(url), new GZIPOutputStream(new FileOutputStream(destination)));
} }
public static void copyFile(InputStream inputStream, OutputStream output) throws IOException { public static void copyFile(InputStream inputStream, OutputStream output) throws IOException {
byte[] buffer = new byte[1024]; byte[] buffer = new byte[4096];
int length; int length;
while ((length = inputStream.read(buffer, 0, 1024)) != -1) { while ((length = inputStream.read(buffer, 0, 4096)) != -1) {
output.write(buffer, 0, length); output.write(buffer, 0, length);
} }
inputStream.close(); inputStream.close();