Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- // not an ideal implementation by any means, just an example method
- public class FileIO {
- public static void main(String[] args) throws Exception {
- // create Files, in and out
- File f1 = new File("in.txt");
- File f2 = new File("out.txt");
- try {
- // create instream and outstream
- FileInputStream in = new FileInputStream(f1);
- FileOutputStream out = new FileOutputStream(f2);
- int i;
- // while there is a char to be read, continue writing to outstream
- while ((i = in.read()) != -1) {
- out.write(i);
- }
- // close streams
- in.close();
- out.close();
- }
- // catch any exceptions
- catch (Exception e) {
- System.exit(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement