Java Blog

 
 
 
import java.io.*;

class  CopyBytes
{
    public static void main(String[] args) 
    {
          FileInputStream fis = null;
          FileOutputStream fos = null;

          try{
               fis = new  FileInputStream(\"input.txt\");
               fos = new FileOutputStream(\"output.txt\");

               int ch;
               while((ch=fis.read())!=1){
                    fos.write(ch);
               }
             }catch(IOException e)
                {
                  System.out.println(e);
                  System.exit(-1);
                }
            finally{
                 try{
                       fos.close();
                       fis.close();
                 }
                 catch(IOException e){}
            }

    }
}

    Related Post:
  1. Program to show an example of creating a class and using its object

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

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

  4. Program to perform Merge Sort

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

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

  7. Program to show the use of For Loop

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

  9. Program to show an example of using initialization block to initialize the data members of a class

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

  11. Program to determine the sum of the following harmonic series for a given value of n

  12. Program of reading and writing primitive data

  13. CORBA program for displaying the date and time of the server machine, client machine and the difference between these two date and time

  14. An applet program that concatenates two string entered in TextField

  15. Program of an applet to display alternate filled and empty circle

  16. Program to show the use of Bitwise Operator (~) Complement

  17. Program to show the use of Switch Statement for the same statement for several different case labels

  18. Program to declare, initialize and print a String object

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

  20. File Handling- JAVA

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