×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    14

    How to open resource files in 6310i

    I've previously developed an application that runs fine on Siemens' SL45. Now I'm trying to port it to 6310i but I can't understand how I can open a data input stream to a file that is located inside the jar.

    In Siemens this works:

    DataInputStream dis = Connector.openDataInputStream("resource:file.dat"

    But this isn't the standard way, it should be "file://". I haven't tested this on Siemens but on 6310i none of these work:

    file://
    file:
    resource:
    res:
    resource://

    I bet there is an easy answer but I can't find it in the documentation.

    Thanks.

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    229

    RE: How to open resource files in 6310i

    This is the standard MIDP way, and it is fairly simple!

    From an instance method:

    InputStream in = getClass().getResourceAsStream("/file.dat"

    Or static method:

    InputStream in = new Object().getClass().getResourceAsStream("/file.dat"

    Obviously:

    DataInputStream din = new DataInputStream(in);

    Hope this helps,

    Steve

Posting Permissions

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