Problème de suppression de File
Bonjour, je voudrais supprimer des fichiers temp que je créé mais que delete() n'arrive pas à supprimer. Merci pour toutes vos réponse. voici mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| if (fichierMatrix.getName().contains(".xls"))
{
File temp = new File(ensemblePourGeneration.getDestination().getParentFile()+File.separator+fichierMatrix.getName()+".txt");
FileInputStream fis = null;
try {
fis = new FileInputStream(fichierMatrix.getPath());
HSSFWorkbook file = new HSSFWorkbook(new POIFSFileSystem(fis));
ExcelExtractor extractor = new ExcelExtractor(file);
extractor.setFormulasNotResults(true);
extractor.setIncludeSheetNames(false);
String text = (extractor.getText());
text=text.replaceAll("\n","\r\n");
FileWriter fw=new FileWriter(temp);
fw.write(text);
fw.close();
System.out.println(fichierMatrix.getConfigFichierMatrix().getBaliseExi());
FichierMatrix fichierMatrixdoc = new FichierMatrix(temp, fichierMatrix.getConfigFichierMatrix());
//fichierMatrixdoc.FichierMatrix(temp, fichierMatrix.getConfigFichierMatrix());
statusBarMatrix.setLabel(fichierMatrixdoc.toString());
if(!ensembleBalisesAmont.ajoutertableau(fichierMatrixdoc))
return false;
statusBarMatrix.incrementeProgressBar();
} catch (FileNotFoundException file) {
// Traitement de l'exception :
System.out.println("Ce fichier n'existe pas ou ne peux pas \352tre lut !");
} catch (IOException file) {
// Traitement des autres exceptions de lecture :
file.printStackTrace();
} finally {
// Fermeture propre du flux :
try {fis.close();}
catch (IOException e) {}
}
temp.delete();
} |
Pourtant je ferme bien mon FileWriter... enfin je crois????????:cry::cry: