Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
3927 connectés 

 


Dernière réponse
Sujet : pb d'erreur d'ouverture de fichier en java
sacrebleu rajoute ca :
 
try {
 
int returnVal = jfc.showSaveDialog(null);  
if(returnVal == JFileChooser.APPROVE_OPTION) {  
 
File f=jfc.getSelectedFile();  
if(!(d.data.isEmpty())){  
 for(int i=0; i<d.data.size();i++){  
  fig=((Figure)d.data.elementAt(i));  
  FileOutputStream ostream = new FileOutputStream(f);  
  ObjectOutputStream o = new ObjectOutputStream(ostream);  
  o.writeObject(fig);  
 }  
}  
 
] catch ( java.io.FilePermission e ) {
}  
 
a+

Votre réponse
Nom d'utilisateur    Pour poster, vous devez être inscrit sur ce forum .... si ce n'est pas le cas, cliquez ici !
Le ton de votre message                        
                       
Votre réponse


[b][i][u][strike][spoiler][fixed][cpp][url][email][img][*]   
 
   [quote]
 

Options

 
Vous avez perdu votre mot de passe ?


Vue Rapide de la discussion
sacrebleu rajoute ca :
 
try {
 
int returnVal = jfc.showSaveDialog(null);  
if(returnVal == JFileChooser.APPROVE_OPTION) {  
 
File f=jfc.getSelectedFile();  
if(!(d.data.isEmpty())){  
 for(int i=0; i<d.data.size();i++){  
  fig=((Figure)d.data.elementAt(i));  
  FileOutputStream ostream = new FileOutputStream(f);  
  ObjectOutputStream o = new ObjectOutputStream(ostream);  
  o.writeObject(fig);  
 }  
}  
 
] catch ( java.io.FilePermission e ) {
}  
 
a+
Boing avec ce code :
 

Code :
  1. int returnVal = jfc.showSaveDialog(null);
  2. if(returnVal == JFileChooser.APPROVE_OPTION) {
  3. File f=jfc.getSelectedFile();
  4. if(!(d.data.isEmpty())){
  5.  for(int i=0; i<d.data.size();i++){
  6.   fig=((Figure)d.data.elementAt(i));
  7.   FileOutputStream ostream = new FileOutputStream(f);
  8.   ObjectOutputStream o = new ObjectOutputStream(ostream);
  9.   o.writeObject(fig);
  10.  }
  11. }
  12. }


 
 
j'obtient ce type d'erreur :
 

Code :
  1. C:\java\Tabl.java:138: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
  2.       FileOutputStream ostream = new FileOutputStream(jfc.getSelectedFile());
  3.                                                                                    ^
  4. C:\java\Tabl.java:139: unreported exception java.io.IOException; must be caught or declared to be thrown
  5.       ObjectOutputStream o = new ObjectOutputStream(ostream);
  6.                                                                                ^
  7. C:\java\Tabl.java:140: unreported exception java.io.IOException; must be caught or declared to be thrown
  8.       o.writeObject(fig);
  9.                                                          ^
  10. 3 errors


 
 
Je me doute qu'il ne trouve pas le fichier f mais je lui demande pas de le trouver, puisque la boite de dialogue sera censée lui donner ...
 
Bref je comprends poa ...


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)