tags:

views:

35

answers:

1

I have a JavaME application called ParseExample. I can't seem to access the files inside the project's folders using the code below.

 FileConnection fconn = (FileConnection) Connector.open("/ParseExample/service1.xml", Connector.READ_WRITE);

Here is the structure: ParseExample -Source Packages -XMLCreatorExample.java -service1.xml ---> I want to read and write to this file

Sorry for the noob question. Am I using this wrong? What path should be used? Or is there any other class that is supposed to be used instead of this?

A: 

Try this and see where it writes to.
Also note the format for file url.
Sourced from http://developers.sun.com/mobility/apis/articles/fileconnection/index.html

public void createFile() {
   try {
      FileConnection filecon = (FileConnection)
         Connector.open("file:///ParseExample/service1.xml");
      // Always check whether the file or directory exists.
      // Create the file if it doesn't exist.
      if(!filecon.exists()) {
         filecon.create();
      }
      filecon.close();
   } catch(IOException ioe) {
   }
}
Romain Hippeau
Try this and see where it writes to. -> I'm sorry I don't get your point. How can I try and find it?
cancelledout
@cancelledout First try the proper format for the file url in your code and see if that works.
Romain Hippeau
I have tried the formats in the link you posted and I don't think there is a right one for accessing files inside a projects folder. =X
cancelledout