Fallback works like a charm

This commit is contained in:
vanitasvitae 2017-07-03 10:13:00 +02:00
parent 4a8251fbe5
commit 63aa2f017c
Signed by: vanitasvitae
GPG Key ID: 62BEE9264BF17311
2 changed files with 4 additions and 3 deletions

View File

@ -55,13 +55,14 @@ public class ReceiveTask implements Runnable {
byte[] filebuf = new byte[transfer.getSize()]; byte[] filebuf = new byte[transfer.getSize()];
int read = 0; int read = 0;
byte[] bufbuf = new byte[2048]; byte[] bufbuf = new byte[4096];
LOGGER.log(Level.INFO, "Begin receiving."); LOGGER.log(Level.INFO, "Begin receiving bytes.");
while (read < filebuf.length) { while (read < filebuf.length) {
int r = inputStream.read(bufbuf); int r = inputStream.read(bufbuf);
if (r >= 0) { if (r >= 0) {
System.arraycopy(bufbuf, 0, filebuf, read, r); System.arraycopy(bufbuf, 0, filebuf, read, r);
read += r; read += r;
LOGGER.log(Level.INFO, "Read " + r + " (" + read + " of " + filebuf.length + ") bytes.");
} else { } else {
break; break;
} }

View File

@ -58,6 +58,7 @@ public class SendTask implements Runnable {
LOGGER.log(Level.INFO, "WRITE"); LOGGER.log(Level.INFO, "WRITE");
outputStream.write(filebuf); outputStream.write(filebuf);
outputStream.flush();
LOGGER.log(Level.INFO, "WRITING FINISHED"); LOGGER.log(Level.INFO, "WRITING FINISHED");
} }
catch (IOException e) { catch (IOException e) {
@ -70,7 +71,6 @@ public class SendTask implements Runnable {
inputStream.close(); inputStream.close();
LOGGER.log(Level.INFO, "InputStream closed."); LOGGER.log(Level.INFO, "InputStream closed.");
} }
} catch (IOException e) { } catch (IOException e) {
LOGGER.log(Level.SEVERE, "Could not close session.", e); LOGGER.log(Level.SEVERE, "Could not close session.", e);
} }