I have a method that takes the files I want to .rar from one folder and saves it to another, but when I open the file it is corrupted.
try {
//Origem
File arquivoOrigem = new File(path);
FileReader fis = new FileReader(arquivoOrigem);
BufferedReader bufferedReader = new BufferedReader(fis);
StringBuilder buffer = new StringBuilder();
String line = "";
while ((line = bufferedReader.readLine()) != null) {
buffer.append(line).append("\n");
}
fis.close();
bufferedReader.close();
//Destino
File arquivoDestino = new File(frmMenuInicial.caminhoTemporario+"/" + nomeArquivo + ".zip");
System.err.println("TESTE: "+frmMenuInicial.caminhoTemporario+"/" + nomeArquivo + ext);
FileWriter writer = new FileWriter(arquivoDestino);
writer.write(buffer.toString());
writer.flush();
writer.close();
JOptionPane.showMessageDialog(null, "Arquivo Salvo com Sucesso!\nPasta Destino: "+frmMenuInicial.caminhoTemporario, "Sucesso", JOptionPane.INFORMATION_MESSAGE);
//Process p;
//p = Runtime.getRuntime().exec(path);
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Erro ao tentar salvar Arquivo!\nVerifique se o Arquivo ainda exixte.\n"+e, "ERRO!", JOptionPane.ERROR_MESSAGE);
}