Source Code : Copy file character by character with FileReader and FileWriter

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Copy file character by character with FileReader and FileWriter


import java.io.FileReader;
import java.io.FileWriter;

class FileCopy {

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

    FileReader fr = new FileReader(args[0]);

    // Create a file writer
    FileWriter fw = new FileWriter(args[1]);

    // Read and copy characters
    int i;
    while ((i = fr.read()) != -1) {
      fw.write(i);
    }
    fw.close();

    fr.close();
  }
}

 

Thank with us