Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bsideup committed Feb 21, 2017
1 parent d15b41e commit 4cf8a91
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,15 @@ InetSocketAddress start() throws IOException {
FileOutputStream fileOut = new FileOutputStream(randomAccessFile.getFD());
int n;
while (true) {
final byte[] buffer = new byte[1024];
if (IOUtils.EOF == (n = socketIn.read(buffer))) {
break;
synchronized (randomAccessFile) {
final byte[] buffer = new byte[1024];
if (IOUtils.EOF == (n = socketIn.read(buffer))) {
break;
}
fileOut.write(buffer, 0, n);
fileOut.flush();
System.out.println("Sent " + n + " bytes to a file. Value: " + new String(buffer, 0, n));
}
fileOut.write(buffer, 0, n);
System.out.println("Sent " + n + " bytes to a file. Value: " + new String(buffer, 0, n));
}
log.info("Done redirecting input");
} catch (Exception e) {
Expand All @@ -117,13 +120,15 @@ InetSocketAddress start() throws IOException {
FileInputStream fileIn = new FileInputStream(randomAccessFile.getFD());
int n;
while (true) {
final byte[] buffer = new byte[1024];
if (IOUtils.EOF == (n = fileIn.read(buffer))) {
break;
synchronized (randomAccessFile) {
final byte[] buffer = new byte[1024];
if (IOUtils.EOF == (n = fileIn.read(buffer))) {
break;
}
System.out.println("Read " + n + " bytes from a file. Value: " + new String(buffer, 0, n));
socketOut.write(buffer, 0, n);
socketOut.flush();
}
System.out.println("Read " + n + " bytes from a file. Value: " + new String(buffer, 0, n));
socketOut.write(buffer, 0, n);
socketOut.flush();
}
log.info("Done redirecting output");
} catch (Exception e) {
Expand Down

0 comments on commit 4cf8a91

Please sign in to comment.