You're probably in the wrong directory. I'd suggest you first create a File, then print the full path to that file, before you create the input stream - or just print it when an error occurs on the open. Something like this:

 File file = new File(f);
 FileInputStream fin = null;
 try {
   fin = new FileInputStream(f);
 } catch (FileNotFoundException e) {
   System.err.println("Didn't find file " + file.getAbsolutePath());
   e.printStackTrace();
 }

 - Dennis

Gilles Devaux wrote:

Hi Bao,
The exception is sent by the java.io.FileInputStream class so I don't think it's the 
unmarshaller.

-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Bao Trang
Envoyé : vendredi 24 septembre 2004 22:12
À : [EMAIL PROTECTED]
Objet : [jibx-users] What am I doing wrong here? File I/O problem

For some reason I keep getting "file not found" exceptions.  I know that the file 
exists.  If I copy the file to the same directory that my project is in, then it will load.

I've done System.out.println's on the input parameter.  The file is there!  Is this me 
or the unmarshaller?

Here's my code snippet:

   public static Project readFrom(File f) {
       try {
           IBindingFactory bfact = BindingDirectory.getFactory(Project.class);
           IUnmarshallingContext uctx = bfact.createUnmarshallingContext();

           FileInputStream file = new FileInputStream(f);

           Object obj = uctx.unmarshalDocument(file, null);

           Project proj = (Project) obj;
           return proj;
       }
       catch (JiBXException e) {
           e.printStackTrace();
       }
       catch (FileNotFoundException fe) {
           fe.printStackTrace();
       }

Here's the stack trace:

java.io.FileNotFoundException: filename.xml (The system cannot find the file specified)
       at java.io.FileInputStream.open(Native Method)
       at java.io.FileInputStream.<init>(FileInputStream.java:106)
       at domain.Project.readFrom(Project.java:257)
       at model.Controller.openProject(MainController.java:98)
       at model.Actions$2.actionPerformed(Actions.java:162)
       at 
com.jgoodies.swing.util.ActionLabel$ActionMouseAdapter.mouseClicked(ActionLabel.java:446)
       at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:211)
       at java.awt.Component.processMouseEvent(Component.java:5103)
       at java.awt.Component.processEvent(Component.java:4897)
       at java.awt.Container.processEvent(Container.java:1569)
       at java.awt.Component.dispatchEventImpl(Component.java:3615)
       at java.awt.Container.dispatchEventImpl(Container.java:1627)
       at java.awt.Component.dispatchEvent(Component.java:3477)
       at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to