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 of creating a file using text fields in windows

  2. Program to copy the elements of an array into another array in reverse order and print them

  3. Program that will read real number from the keyboard and print the following output in one line: small Integer not less The Given Number Largest Int

  4. Develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side, executed on server

  5. Program to Display Output in triangular shape

  6. program which takes a long sentence from the client passes to the server,server separates out each word and sends them back to client in reverse order

  7. Program to show an example of creating a class and using its object

  8. CORBA based application for addition of two mathematical expressions of the form (ax + by) and displaying the result on client side

  9. Program to show the use of operator (<<) Shift Left filling with zero from the right

  10. Program of writing Bytes to a File

  11. Program to read the ballots and count the votes cast for each candidate using an array variable count

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

  13. Program to display reverse $ tree

  14. Develop a CORBA based application for addition of two complex numbers and displaying the result on client side

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

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

  17. Program to show the use of Increment and Decrement Operators

  18. Program to show the comparing of Strings for equality

  19. Even no or Prime no?????

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

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