comparison src/goodjava/io/IoUtils.java @ 1494:91c167099462

more io
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 03 May 2020 11:51:31 -0600
parents 471ef3e6a84e
children f04bfbb08721
comparison
equal deleted inserted replaced
1493:471ef3e6a84e 1494:91c167099462
33 33
34 public static void link(File from,File to) throws IOException { 34 public static void link(File from,File to) throws IOException {
35 Files.createLink( to.toPath(), from.toPath() ); 35 Files.createLink( to.toPath(), from.toPath() );
36 } 36 }
37 37
38 public static long copyAll(InputStream in,OutputStream out) 38 public static void copyAll(InputStream in,OutputStream out)
39 throws IOException 39 throws IOException
40 { 40 {
41 long total = 0;
42 byte[] a = new byte[8192]; 41 byte[] a = new byte[8192];
43 int n; 42 int n;
44 while( (n=in.read(a)) != -1 ) { 43 while( (n=in.read(a)) != -1 ) {
45 out.write(a,0,n); 44 out.write(a,0,n);
46 total += n;
47 } 45 }
48 return total;
49 } 46 }
50 47
51 } 48 }