Parent Directory | Revision Log | Patch
revision 1.1 by benja, Tue Aug 13 23:01:27 2002 UTC | revision 1.2 by benja, Sat Nov 16 05:59:45 2002 UTC | |
---|---|---|
# | Line 36 public class CopyUtil { | Line 36 public class CopyUtil { |
36 | */ | */ |
37 | static public int copy(InputStream from, OutputStream to, int blockSize) | static public int copy(InputStream from, OutputStream to, int blockSize) |
38 | throws IOException { | throws IOException { |
39 | byte[] buf = new byte[blockSize]; | try { |
40 | int bytesCopied = 0; | byte[] buf = new byte[blockSize]; |
41 | //p("start copying"); | int bytesCopied = 0; |
42 | while(true) { | //p("start copying"); |
43 | //p("read "); | while(true) { |
44 | int r = from.read(buf); | //p("read "); |
45 | //p("check("+r+") "); | int r = from.read(buf); |
46 | if(r == -1) break; | //p("check("+r+") "); |
47 | //p("write "); | if(r == -1) break; |
48 | to.write(buf, 0, r); | //p("write "); |
49 | bytesCopied += r; | to.write(buf, 0, r); |
50 | } | bytesCopied += r; |
51 | //p("... all read."); | } |
52 | from.close(); | //p("... all read."); |
53 | to.close(); | return bytesCopied; |
54 | return bytesCopied; | } finally { |
55 | from.close(); | |
56 | to.close(); | |
57 | } | |
58 | } | } |
59 | ||
60 | /** Read data from an input stream into a byte array by copying it into | /** Read data from an input stream into a byte array by copying it into |
|
savannah-hackers-public@gnu.org | ViewVC Help |
Powered by ViewVC 1.1.26 |