Voila mon code qui fonctionne très bien sous XP mais pas sous windows 2000?! Pourquoi?
La je seche!!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public void saveAs() { FileOutputStream fileOutputStream = null; ObjectOutputStream objectOutputStream = null; File saveFile; String pathFile; String extension; FiltrePourFileChooser filtreMatrix = new FiltrePourFileChooser("Ficher MATRIX",".matrix"); JFileChooser fileChooser = new JFileChooser(); fileChooser.setAcceptAllFileFilterUsed(false); fileChooser.addChoosableFileFilter(filtreMatrix); fileChooser.setCurrentDirectory(fichierDeDepart); DefaultMutableTreeNode projectToSave = getParentProject(getSelectedNode()); Projet projetAssocie = (Projet) projectToSave.getUserObject(); int choix = fileChooser.showDialog(this, "Enregistrer sous"); if(choix == JFileChooser.APPROVE_OPTION) { try { saveFile = fileChooser.getSelectedFile(); fichierDeDepart = saveFile.getParentFile(); extension = ((FiltrePourFileChooser)fileChooser.getFileFilter()).getExtension(); // mise en forme de l'extension pathFile = saveFile.toString(); if(pathFile.indexOf(".")==-1) pathFile=pathFile+extension; else pathFile=pathFile.substring(0,pathFile.indexOf("."))+extension; saveFile = new File(pathFile); fileOutputStream = new FileOutputStream(saveFile); objectOutputStream = new ObjectOutputStream(fileOutputStream); projetAssocie.setSaved(true); projetAssocie.setFichierDeSauvegarde(saveFile); objectOutputStream.writeObject(projectToSave); objectOutputStream.flush(); } catch(Exception exception) {exception.printStackTrace();} finally { try {objectOutputStream.close();} catch(Exception exception) {} try {fileOutputStream.close();} catch(Exception exception) {} } } tree.repaint(); return; }
Partager