Problème de path sous linux
Salut,
J'avais fait un soft d'essai afin de créer un fichier puis d'en restaurer ses valeurs ensuite. Il s'avère que le fichier ne se crée pas sous linux. J'aurais aimer que sous /home/test.properties, un fichier puisse se créer.
J'ai comme intuition que les droits peuvent être une partie du problème, mais en /home ça ne devrais pas.
J'ai comme autre intuition que /home//test.properties ne suffit pas et que, du coup le path n'est pas correct.
Pour exemple de bout de 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
|
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
// Créer un properties
String urlFichier;
urlFichier = "/home/Test.properties";
String Section = "Section";
String Cle = "Cle";
String Donnee = "Ma donnée1";
Properties propFichier = new Properties();
try {
propFichier.setProperty(Section + "." + Cle, Donnee);
OutputStream FichierSortie = new FileOutputStream(urlFichier);
OutputStreamWriter fw = new OutputStreamWriter(FichierSortie, "ISO-8859-1");
propFichier.store(fw, "Test commentaire");
fw.flush();
fw.close();
jTextArea1.setText("Fichier crée sous: " + urlFichier + "\n");
jTextArea1.setText(Section + "." + Cle + " = " + Donnee +"\n");
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
} |
Oh !
A l'exécution, tout va bien mais à la création du fichier, voila les messages que me retourne netbeans :
Citation:
run:
java.io.FileNotFoundException: /home/Test.properties (Permission denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:209)
at java.io.FileOutputStream.<init>(FileOutputStream.java:99)
at Form1.jMenuItem1ActionPerformed(Form1.java:186)
at Form1.access$200(Form1.java:22)
at Form1$3.actionPerformed(Form1.java:76)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:374)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:829)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:873)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
at java.awt.Component.processMouseEvent(Component.java:6108)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:5873)
at java.awt.Container.processEvent(Container.java:2105)
at java.awt.Component.dispatchEventImpl(Component.java:4469)
at java.awt.Container.dispatchEventImpl(Container.java:2163)
at java.awt.Component.dispatchEvent(Component.java:4295)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4461)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4125)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4055)
at java.awt.Container.dispatchEventImpl(Container.java:2149)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4295)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:604)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
GÉNÉRATION TERMINÉE (durée totale* 38 secondes)
Ca ressemble à un problème de droit sous linux. Une confirmation ?
Si vous voyais d'où cela peut venir et comment corriger cela, je suis preneur. :ccool: