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 to this Topic
Type: Question • Score: 0 • Views: 1,380 • Replies: 0
No top replies

 
 

Related Topics

Clone of Micosoft Office - Question by Advocate
Do You Turn Off Your Computer at Night? - Discussion by Phoenix32890
The "Death" of the Computer Mouse - Discussion by Phoenix32890
Windows 10... - Discussion by Region Philbis
Surface Pro 3: What do you think? - Question by neologist
Windows 8 tips thread - Discussion by Wilso
GOOGLE CHROME - Question by Setanta
.Net and Firefox... - Discussion by gungasnake
Hacking a computer and remote access - Discussion by trying2learn
 
  1. Forums
  2. » copy a file in other
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.09 seconds on 12/22/2024 at 08:14:30