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 read the ballots and count the votes cast for each candidate using an array variable count

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

  3. Program to display bank account

  4. Program to show the use of some Math Methods

  5. An applet program to display text

  6. Program to convert the given temperature in faherenhiet to celsius using the following conversion formula C= F- 32/1.8

  7. An applet program that displays Text at the center of the string which is passed as parameter

  8. Corba program of reverse string

  9. Program to show the use of Bitwise Operator (&) AND

  10. An applet program of showing new document using showDocument(URL) method

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

  12. An applet program that creates string dynamically and displays it

  13. An applet program that display blinking rectangle

  14. Program to show the use of If-Else Statement

  15. Program to show an example of extracting subStrings from a String

  16. Program to generate Fibonacci Series of a given number

  17. RMI based application, which reads a file with list of marks of student from a client, send it to server and find how many students having distinct

  18. Program which calls the method sort(int []a) which throws the Exception ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException

  19. Even number ,Prime no. ,Factorial of a number

  20. An applet program to draw different shapes

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