diff src/goodjava/rpc/RpcCon.java @ 1493:471ef3e6a84e

more io
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 03 May 2020 00:12:15 -0600
parents aaac1d29edea
children 91c167099462
line wrap: on
line diff
--- a/src/goodjava/rpc/RpcCon.java	Sat May 02 22:25:56 2020 -0600
+++ b/src/goodjava/rpc/RpcCon.java	Sun May 03 00:12:15 2020 -0600
@@ -3,9 +3,7 @@
 import java.io.InputStream;
 import java.io.BufferedOutputStream;
 import java.io.IOException;
-import java.io.EOFException;
 import java.net.Socket;
-import java.nio.charset.StandardCharsets;
 import java.util.List;
 import goodjava.parser.ParseException;
 import goodjava.json.JsonParser;
@@ -13,6 +11,7 @@
 import goodjava.io.BufferedInputStream;
 import goodjava.io.DataInputStream;
 import goodjava.io.DataOutputStream;
+import goodjava.io.IoUtils;
 
 
 public class RpcCon {
@@ -58,13 +57,7 @@
 		try {
 			out.writeString(json);
 			if( in != null ) {
-				byte[] a = new byte[8192];
-				long total = 0;
-				int n;
-				while( (n=in.read(a)) != -1 ) {
-					out.write(a,0,n);
-					total += n;
-				}
+				long total = IoUtils.copyAll(in,out);
 				if( total != lenIn ) {
 					close();
 					throw new RpcError("InputStream wrong length "+total+" when should be "+lenIn);