Java Tutorial

 
 
 
 
import java.io.*;

class  CopyChar
{
    public static void main(String[] args) 
    {
           File infile = new File(\"infile.txt\");
           File outfile = new File(\"Outfile.txt\");
           FileReader fr=null;
           FileWriter fw=null;

           try{
                fr = new FileReader(infile);
                fw = new FileWriter(outfile);

               int ch;
               //FileReader Class which is subclass of InputSteamReader
               //InputStreamReader class converts Strings or character data
               //into Byte which are in form of integers. 
               //so ch is of int type

               while((ch=fr.read())!=-1){      //-1 indicates end-of-file (eof)
                   fw.write(ch);
               }

            }catch(IOException e)
            {
                  System.out.println(e);
                  System.exit(-1);
            }
            finally{
                 try{
                       fr.close();
                       fw.close();
                 }
                 catch(IOException e){}
            }

    }
}

    Related Post:
  1. An applet program to give demo of getDocumentBase() and getCodeBase() methods

  2. Program to reverse the number eg given no : - 12345, output want :- 54321

  3. Program to show the use of Logical OR Operator (|) in If Statements

  4. Word list program that reads a text file and makes an alphabetical list of all the words in that file. The list of words is output to another file

  5. Program to show the use of While Loop

  6. Program sets up a String variable containing a paragraph of text of your choice. Extract the words from the text and sort them into alphabetical order

  7. Create an interface coversions. Which have the following functions Inchestomillimeters(), hptowatts(),wattstohp(),poundstogram(),gramtopounds()

  8. File handling program to count number of characters in a file

  9. Program, which creates a three thread. One thread display the numbers from 1 to 5, second thread display the square root of that number etc

  10. Program to compare Strings by compring successive corresponding characters, starting with the first character in each String

  11. Define an array of ten String elements each containing an arbitrary string of the form “month/day/year”

  12. Program of concatenating and Buffering files

  13. Program which simulate the dictionary in java

  14. An applet program to display moving banner

  15. Do the following for the Array Insert the element in the array,delete an element from the array,search for a particular element Create multiple thread

  16. Program to search an element in an array using Linear Search

  17. An applet program to draw circle in center of the canvas

  18. RMI program of count server and client

  19. GUI application in java, which enter the details of a student and on the submit display the details of the student

  20. Program to print triangle of numbers

 
 
Didn't find what you were looking for? Find more on File handling program to copy characters from one file to another