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 in CORBA which takes a long sentence from the client (at least 7 words), passes to the server, server separates out each word

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

  3. Write a program for restaurant

  4. An applet program to display moving banner

  5. Program to show an example of Polymorphism

  6. Program to calculate the frequency for different values of C starting from 0.01 to 0.1 in steps of 0.01

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

  8. corba program of client and a DNS server where given a URL the server sends back an IP address

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

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

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

  12. Program of UDP datagram

  13. Game application in CORBA for which player will guess a number between 1 to 100, which will be compared to the random number generated by the class

  14. Program to show an example of Overriding a Base Class Method

  15. Program of creating a file using text fields in windows

  16. Write a program for restaurant

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

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

  19. Program to show the use of operator (>>>) Shift Right, filling with zeros from the left

  20. An applet program that display blinking rectangle

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