Tenho um arquivo no c:\ quando vou criar funciona, porém se já existe eu não consigo excluir!
public class ExportaExcel {
private final GeraRelatorio gerando;
private final String filename;
public ExportaExcel() {
this.gerando = new GeraRelatorio();
this.filename = "C:\\Users\\Inspiron 5557\\Documents\\relatoriosimples.xls";
}
public void geradorExcel(List<RelatorioLimite> relatorio, boolean comdetalhe){
File arquivo = new File(filename);
if (arquivo.exists()) {
arquivo.delete();
}
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Limites");
try {
FileOutputStream out = new FileOutputStream(arquivo);
workbook.write(out);
out.close();
Util.mostrarMensagemSucesso("Sucesso", "Arquivo excel gerado localizado em : C:\\Users\\Inspiron 5557\\Documents\\relatoriosimples.xls");
} catch (FileNotFoundException ex) {
Util.mostrarMensagemErro("Erro", "" + ex.getMessage());
} catch (IOException ex) {
Util.mostrarMensagemErro("Erro", "" + ex.getMessage());
}
}
}