package br.com.neto.main;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import br.com.neto.util.Constantes;
public class EscreverArquivoTxt {
@SuppressWarnings("static-access")
public static void main(String[] args) {
Constantes c = Constantes.getInstance();
File arquivo = new File(c.FILE_DIRETORIO + c.SLASH + "album.txt");
File arquivoBkp = new File(c.FILE_DIRETORIO + c.SLASH + "album_bkp.txt");
// Extrutura try-with-resources do Java 7
try(BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(arquivo)));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(arquivoBkp)));){
String line = br.readLine();
do{
bw.write(line);
bw.newLine();
}while((line = br.readLine()) != null);
}catch(IOException ioe){
System.out.println(ioe.getMessage());
}
}
}