skip to main | skip to sidebar

Java Programs and Examples with Output

Pages

▼
 
  • RSS
  • Twitter
Saturday, October 13, 2012

Java Code of copying and pasting a file

Posted by Raju Gupta at 2:00 PM – 0 comments
 
This code contains simple logic of copy paste of a file content

import java.io.*;
public class FileMain 
{
 public static void main(String []args) throws IOException

 {    
  FileInputStream f1= new FileInputStream("/give_file_name.txt");// creats an input stream  which points a file
  OutputStream f2= new FileOutputStream("/a.txt");// creats out put stream   int i= f1.available();// checks sise of the file
  // System.out.println(i);
  for(int q=0;q<=i;q++ )
  {  
   f2.write((char)f1.read());
  }

 }
}


Labels: Java File Example

Leave a Reply

Newer Post Older Post
Subscribe to: Post Comments ( Atom )
  • Popular
  • Recent
  • Archives
Powered by Blogger.
 
 
 
© 2011 Java Programs and Examples with Output | Designs by Web2feel & Fab Themes

Bloggerized by DheTemplate.com - Main Blogger