From a6e42a8934085511076981071e7e90ed3d3779c4 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 10 Nov 2023 16:13:18 -0500 Subject: [PATCH] reading --- src/shared/FileHeader.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/shared/FileHeader.java b/src/shared/FileHeader.java index 25e794a..e7e639c 100644 --- a/src/shared/FileHeader.java +++ b/src/shared/FileHeader.java @@ -41,6 +41,7 @@ public class FileHeader { writer.writeInt(amount); writer.write(bytes, 0, amount); } + writer.writeInt(0); } catch (Exception ignored) { } } @@ -48,9 +49,13 @@ public class FileHeader { void receive(DataInputStream reader) { try { String relative = reader.readUTF(); - - - DataOutputStream writer = new DataOutputStream(new BufferedOutputStream(new FileOutputStream())); + DataOutputStream writer = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(relative))); + int size = 0; + while ((size = reader.readInt()) > 0){ + byte[] data = new byte[size]; + int amount = reader.read(data, 0, size); + writer.write(data, 0, amount); + } } catch (Exception ignored){ } }