home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-23 | 1.2 KB | 42 lines |
- import java.io.*;
-
- public class FileIO
- {
- public static void main(String[] args)
- {
- try
- {
- // open args[0] for input
- FileInputStream in = new FileInputStream(args[0]);
-
- // add buffering to that InputStream
- BufferedInputStream bin =
- new BufferedInputStream(in);
-
- // open args[1] for output and add buffering to
- // it as well
- FileOutputStream out = new FileOutputStream(args[1]);
- BufferedOutputStream bout =
- new BufferedOutputStream(out);
-
- // now read as long as there is something to read
- byte bArray[] = new byte[256];
- int nBytesRead;
- while(bin.available() > 0)
- {
- // read up a block - remember how many bytes read
- nBytesRead = bin.read(bArray);
-
- // write that many bytes back out starting
- // at offset 0 in the array
- bout.write(bArray, 0, nBytesRead);
- }
- bout.flush();
- }
- catch(IOException ioe)
- {
- System.out.println(ioe.toString());
- }
- }
- }
-