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 an applet to illustrate BarChart

  2. Program that takes a long sentence and a character from the client and count the occurrence of the character in the sentence at the server side

  3. Program of insertion sort

  4. Program to print triangle of numbers

  5. Program to find a factorial of a given number

  6. Program to compute the sum of the digits of a given integer number. eg: I/o=4 then O/p=4+3+2+1=10

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

  8. Program to perform Merge Sort

  9. Corba program of UDP client server application which sends the news to the client. Server takes the news from the NewsDataFile located at the server

  10. Program to show an example of modifying String objects

  11. Program to display following things on the client machine a)date and time of the server machine b)date and time of the client machine and difference

  12. Program to show an example of getting at characters in a String

  13. An applet program to display Vertical Color Bar

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

  15. RMI servlet program to display message

  16. Program to declare, initialize and print a 2D array of integers

  17. Program that enabled applet calculator

  18. Program for calculating area of a circle on server side,when a client sends request along with given radius and then displaying result on client side

  19. Corba program to Write a Echo server and client with UDP server and client

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

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