import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class CopyFile {

	public static void main(String[] args) {

		String input = "D:\\training\\java\\javaprog\\HelloProject\\input.txt";
		String output = "D:\\training\\java\\javaprog\\HelloProject\\output.txt";
		int i = 0;

		// use try-with-resource to open the file
//		try (FileInputStream fin = new FileInputStream(input); FileOutputStream fout = new FileOutputStream(output)) {
		try (FileReader fin = new FileReader(input); FileWriter fout = new FileWriter(output)) {

			// start reading input and write to output
			do {
				i = fin.read();
				if (i != -1) {
					fout.write(i);
				}
			} while (i != -1);

		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
