Annotation of java/classes/org/w3c/util/IO.java, revision 1.2

1.1       bmahe       1: // IO.java
1.2     ! bmahe       2: // $Id: IO.java,v 1.1 1998/10/29 12:47:40 bmahe Exp $
1.1       bmahe       3: // (c) COPYRIGHT MIT and INRIA, 1998.
                      4: // Please first read the full copyright statement in file COPYRIGHT.html
                      5:  
                      6: package org.w3c.util;
                      7: 
                      8: import java.io.*;
                      9: 
                     10: /**
1.2     ! bmahe      11:  * @version $Revision: 1.1 $
1.1       bmahe      12:  * @author  BenoοΏ½t MahοΏ½ (bmahe@w3.org)
                     13:  */
                     14: public class IO {
                     15: 
                     16:     /**
                     17:      * Copy source into dest.
                     18:      */
                     19:     public static void copy(File source, File dest) 
                     20:        throws IOException
                     21:     {
                     22:        BufferedInputStream in = 
                     23:            new BufferedInputStream( new FileInputStream(source) );
                     24:        BufferedOutputStream out =
                     25:            new BufferedOutputStream( new FileOutputStream(dest) );
                     26:        byte buffer[] = new byte[1024];
                     27:        int read = -1;
                     28:        while ((read = in.read(buffer, 0, 1024)) != -1)
                     29:            out.write(buffer, 0, read);
                     30:        out.flush();
                     31:        out.close();
                     32:        in.close();
                     33:     }
1.2     ! bmahe      34: 
        !            35:     /**
        !            36:      * Copy source into dest.
        !            37:      */
        !            38:     public static void copy(InputStream in, OutputStream out) 
        !            39:        throws IOException
        !            40:     {
        !            41:        BufferedInputStream bin = 
        !            42:            new BufferedInputStream(in);
        !            43:        BufferedOutputStream bout =
        !            44:            new BufferedOutputStream(out);
        !            45:        byte buffer[] = new byte[1024];
        !            46:        int read = -1;
        !            47:        while ((read = bin.read(buffer, 0, 1024)) != -1)
        !            48:            bout.write(buffer, 0, read);
        !            49:        bout.flush();
        !            50:        bout.close();
        !            51:        bin.close();
        !            52:     } 
1.1       bmahe      53:     
                     54: }

Webmaster