My requirement is to copy the content from one master file and paste it in temp file. These files are in .dat file format. The code copy paste the contents perfectly but it comes in one single line. My need is, it should come in new lines instead of one single line.
public static void JavaCopyFile () {
try {
FileReader fr = new FileReader("C:\\Automation\\Master_Template.dat");
BufferedReader br = new BufferedReader(fr);
FileWriter fw = new FileWriter("C:\\Automation\\Temp.dat");
String s;
while ((s = br.readLine()) != null) { // read a line
fw.write(s); // write to output file
fw.flush();
}
br.close();
fw.close();
System.out.println("file copied");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}