×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Beijing/China
    Posts
    153

    Questions about file extensions of resources.

    Hello, everyone

    I am trying to read data from resource files with Class.getResourceAsStream(), and I get some problems.

    It seems related to file extensions.
    It works well with .png and .mid, but failed when i use .txt, .dat and some other extensions defined by myself.

    I am using JBuilder 7, MobileSet 3.0 and Nokia 7210 MIDP SDK 1.0, and here is the involved code segment:
    ---------------------------------------------------------------------------------
    ?_?_?_?_
    >1 InputStream is = getClass().getResourceAsStream("/data.png");
    >2 if(is == null) return ;
    >3 DataInputStream dis = new DataInputStream(is) ;
    // and then some code to read data from dis
    ---------------------------------------------------------------------------------
    When I change the file name "/data.png" to "/data.db" for example, it doesn't work.

    I've studied some examples and searched on this forum for this problem. And extensions other then .png and .mid do work fine.

    Does JBuilder make any differents?
    Any suggestion will be helpful.

    Thanks
    Steven

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Beijing/China
    Posts
    153
    I've resolve it.
    JBuilder seems won't copy files with unacquainted extensions to the output directory automatically.
    Copy the resource files to output directory manually, and then it works fine.

  3. #3
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Slovakia/Bratislava
    Posts
    67
    I've just wonted to reply, I spend half of hour to find the same solution...when some body knows more clever solution let us know...

    or stupidly rename .txt file to .png and you don't have to copy it manually;o)

  4. #4
    Regular Contributor
    Join Date
    Apr 2003
    Location
    Slovakia/Bratislava
    Posts
    67
    more comfortable solution...

    choose some extension e.g. txx [not txt], that will you use for your text files...go to tools/IDE Options/File Types
    and associate txx extension e.g. with "properties file"...you will see your resouce files in project, you will be able to edit it directly from JBuilder and you don't have to copy it manually...
    ---------------------------------------------------

    and the best one

    edit .jbuilder/user.properties file
    add this line
    file.types;custom.1=txt/properties

    and you fake the gui that don't allow you to add extension that is already by default associated [txt is such example]
    Last edited by TomXX; 2003-07-08 at 12:11.

  5. #5
    Registered User
    Join Date
    Jul 2003
    Location
    Finland, Tampere
    Posts
    1,113
    If you use some JBuilder version with Archive Builder, then you can tell it which files to include to which archives.

    The one in JBuilder 9 will even rename files AND pathes if you ask it. It also allows using file masks.

  6. #6
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Beijing/China
    Posts
    153

    Thank you both

    TomXX's solution is wonderful.
    I've tried Archive Builder.
    It's feasible to MIDlet package, but do nothing for run and debug modes in JBuilder.

    Thank both of you.

    Steven
    Last edited by Steven_Ch; 2003-07-08 at 13:47.

  7. #7
    Registered User
    Join Date
    Jul 2003
    Location
    Finland, Tampere
    Posts
    1,113

    Yes you can debug JAR's produced by Archive Builder

    I am doing it right now

    It's very comfortable: You click single button and it gathers, renames, archives and launches everything

    To debug JARS:
    1)Set your JAD file as Run target in Runtime Configurations
    2)Don't obfuscate your archive

Posting Permissions

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