FileInputOutputExample.java Source code

Java tutorial

Introduction

Here is the source code for FileInputOutputExample.java

Source

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public class FileInputOutputExample {
    public static void main(String[] args) throws Exception {

        InputStream is = new FileInputStream("in.txt");
        OutputStream os = new FileOutputStream("out.txt");
        int c;
        while ((c = is.read()) != -1) {
            System.out.print((char) c);
            os.write(c);
        }
        is.close();
        os.close();

    }
}