0
   

copy a file in other

 
 
Reply Mon 15 Jun, 2009 03:41 pm
/* i want to copy the contents of file "5.txt" to "6.txt" ....the contents of bothe the files are initially as shown

content of "5.txt"
room no 4226

content of "6.txt"
Prateek rawal
manit
*/


import java.io.*;

public class copy
{
public static void main(String args[])
{
try
{
String s,s2;
String s1=new String();
BufferedReader b1= new BufferedReader(new FileReader("5.txt"));
PrintWriter p= new PrintWriter(new FileWriter("6.txt"),true);
while((s=b1.readLine())!= null)
{
BufferedReader b2= new BufferedReader(new FileReader("6.txt"));
while((s2=b2.readLine())!=null)
{
s1+=s2;

}
s1+=s;

}
p.println(s1);
p.close();
b1.close();

}
catch(IOException o)
{
o.printStackTrace();
}
}
}


/*i dont get any compilation error but the output is not desirable...please tell me what is the problem*/
  • Topic Stats
  • Top Replies
  • Link/Embed
Type: Question • Score: 0 • Views: 115 • Replies: 0
No replies

 
 

Related Topics

The "Death" of the Computer Mouse - Discussion by Phoenix32890
Blue screen of Death - Question by dagmaraka
How does one uninstall a program? - Question by Woollcott
how do you type pi? - Question by C99
Conficker worm - Discussion by msolga
SYSTRAY MISSING - Discussion by Misti26
Broad Jump Client Foundation - Discussion by Mustang
 
  1. able2know
  2. » copy a file in other
Copyright © 2009 Horizontal Verticals :: Page generated in 0.33 seconds on 11/27/2009 at 05:02:46 Top End