×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    4

    Opening a local database file

    Using the following code
    ....
    String uri = "file:/paris.db";
    System.out.println( "Trying to open [" + uri + "]" );
    InputConnection conn = (InputConnection)Connector.open( uri, Connector.READ );
    InputStream in = conn.openInputStream();
    .....

    to open a local db file located in a "res" directory.

    I always raise a ConnectionNotFoundException. I've tried file:/res/paris.db and absolute pathname, but it's the same.

    I package the res directory in the JAR file using jar ... -C res .

    HELP !

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    101
    Nokia phones (as with most others) don't support file: URLs. To read a file from your JAR, use Class.getResourceAsStream().

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    4
    Oops back from holidays, with my same problem ..
    the getResourceAsStream returns null with no other details

    I actually put a "paris.txt" file in a res disrectory that I pack with my JAR using jar cfm myJar.jar MANIFEST.MF - C Classes . - C res .

    The database is loaded using
    myDB db = DB.load();

    and a static loader :

    public static myDB load()
    {
    Class c = anotherClass.getClass();
    InputStream in = c.getResourceAsStream("paris.txt")

    ...
    }

    I've also tried "res/paris.txt", but the file seems to be packed at the root ..
    Any idea ?

  4. #4
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Canada
    Posts
    101
    I'm not sure if it makes a difference, but I would try "/paris.txt" instead of "paris.txt". Also confirm that your file is named "paris.txt" rather than "Paris.txt" or "paris.TXT".

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    4
    That was it, a "/" !!
    Thanks a lot Liam.
    Ciao.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×