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*/