diff src/goodjava/webserver/Connection.java @ 1493:471ef3e6a84e

more io
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 03 May 2020 00:12:15 -0600
parents fb003c4003dd
children a0a74f5f490a
line wrap: on
line diff
--- a/src/goodjava/webserver/Connection.java	Sat May 02 22:25:56 2020 -0600
+++ b/src/goodjava/webserver/Connection.java	Sun May 03 00:12:15 2020 -0600
@@ -7,6 +7,7 @@
 import goodjava.logging.Logger;
 import goodjava.logging.LoggerFactory;
 import goodjava.parser.ParseException;
+import goodjava.io.IoUtils;
 
 
 final class Connection {
@@ -115,7 +116,7 @@
 	
 			OutputStream out = socket.getOutputStream();
 			out.write(header);
-			copyAll(response.body.content,out);
+			IoUtils.copyAll(response.body.content,out);
 			out.close();
 			socket.close();
 		} catch(IOException e) {
@@ -123,14 +124,4 @@
 		}
 	}
 
-	private static void copyAll(InputStream in,OutputStream out)
-		throws IOException
-	{
-		byte[] a = new byte[8192];
-		int n;
-		while( (n=in.read(a)) != -1 ) {
-			out.write(a,0,n);
-		}
-	}
-
 }