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. Program to print triangle of numbers

  2. Program to ask question and accept answer up to 3 attempt and display right answer if it is wrong

  3. Program to show an example of using user-defined package in a program

  4. Program to show the use of Do-While Loop

  5. 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

  6. Even no or Prime no?????

  7. Socket program of multi client chat server

  8. Program to show an example of Multiple Levels of Inheritance

  9. Application which takes your marks of six subjects from the client side and displays the percentage that you have obtained

  10. An applet program to display text

  11. Corba program to encrypt the text that you want to send on the client side. The server side decrypts it after receiving. Append server time.

  12. File handling program to copy bytes from one file to another

  13. Program which creates an Array of character. Make one function with one argument as a character and that function throw a user defined exception

  14. Program of UDP datagram

  15. Program to change characters in a StringBuffer objects and to reverse its contents

  16. Program to find the number of and sum of all integers greater than 100 and less than 200 that are divisible by 7

  17. Program to read rollno, marks of sub1,sub2 and sub3 and on basis of that display result

  18. Program to show an example of modifying String objects

  19. Program to show the use of some Math Methods

  20. Develop a game application in CORBA for which the player will guess a number between 1 to 100, which will be compared to the random number generated b

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