import java.io.*;
import java.io.IOException;
public class ReadWriteFile{
static File f1 = new File("C:\\source.txt");
static File f2 = new File("C:\\dest.txt");
public String readFile() throws IOException
{
String msg = "";
FileReader fr = new FileReader(f1);
BufferedReader br = new BufferedReader(fr);
msg = br.readLine();
System.out.println(msg);
fr.close();
return msg;
}
public void writeFile(String str) throws IOException
{
FileWriter fr = new FileWriter(f2);
BufferedWriter br = new BufferedWriter(fr);
br.write(str);
fr.close();
}
}
public class Entry {
public static void main(String[] args){
ReadWriteFile f1 = new ReadWriteFile();
try {
f1.writeFile(f1.readFile());
}
catch(IOException e)
{
e.getStackTrace();
}
}
}
What's wrong with this code? I am not getting any output file in the end and no errors nothing..
_______________________________________________________________________
Apart from this What are the best methods to read n write data. Preferably nice tutorial to explain differences between different type of read/write methods. please don't redirect me to sun site.