You Are Here:

Community: Developer Discussion Boards

#1 Old how to read outer file - 2003-12-01, 04:51

Join Date: Aug 2003
Posts: 9
koolgi
Offline
Registered User
my development environment is Jbuilder9 + nokia developer suite2.0¡£I made some files(like a.1, a.2) by notebook,I want to read these files on jb9,but failure:

my code is: InputStream is = getClass.getResourceAsStream("a.1")

but the error is: NullPointerException


i guess that the path is incorrect.
the "a.1" file is at %ProjectName%/src/a.1


my english is poor,i hope i described expressly¡£thank you!
Reply With Quote

#2 Old 2003-12-01, 08:29

Join Date: Jul 2003
Posts: 1,094
Location: Finland, Tampere
doctordwarf
Offline
Super Contributor
I guess your this pointer is null. Do you try this code from within a static method?

Also check that your a.1 file is actually put into JAR file. JBuilder archives automatically only *.png files
Reply With Quote

#3 Old 2003-12-01, 17:45

Join Date: Mar 2003
Posts: 112
ossipetz
Offline
me-2-j :)
use a / before the file-names.
and as stated make sure the files are copied into the classes folder (project-properties - build - resource) and add the extensions to the 'copied' files.
Reply With Quote

#4 Old 2003-12-02, 06:36

Join Date: Aug 2003
Posts: 9
koolgi
Offline
Registered User
my path is:

"HealthVegetables" is my project name. and all the file is at the directory of "HealthVegetables".

HealthVegetables---->src
HealthVegetables---->res
HealthVegetables---->class
HealthVegetables---->temp-jad
HealthVegetables---->bak

i put the "a.1" in the directory "res".

At the Jb9, "project"---->"project properties"---->"Source"---->"Add", and then selecting the directory "res" ---> "OK"
Reply With Quote

#5 Old 2003-12-02, 06:39

Join Date: Aug 2003
Posts: 9
koolgi
Offline
Registered User
"PushPuzzle" game sample is at J2meWTK, it is successful to read the outer file.

if you use jb9 , you can open the project file(game.jpx) at "JBuilder9\j2mewtk1.0.4\apps\games", it has a PushPuzzleCanvas.java at "PushPuzzle "package, at line 264.
Reply With Quote

#6 Old nokia's sdk and sun's ri are different - 2003-12-02, 10:17

Join Date: Dec 2003
Posts: 5
cn.dog.blackdog
Offline
Registered User
a sample:

$workDirectory/src/res/conf.txt

InputStream in = getClass().getResourceAsStream( "/res/conf.txt");


it works well.
Reply With Quote

#7 Old i run the PushPuzzle, and got the result as followings - 2003-12-02, 10:27

Join Date: Dec 2003
Posts: 5
cn.dog.blackdog
Offline
Registered User
D:\JBuilder9\j2mewtk1.0.4\bin\emulator.exe -classpath "D:\JBuilder9\j2mewtk1.0.4\apps\games\classes;" -Xdevice:DefaultColorPhone -Xdescriptor:"D:\JBuilder9\j2mewtk1.0.4\apps\games\jad-temp\PushPuzzle.jad"

Could not find the game board for level 1

Execution completed successfully
68917 bytecodes executed
23 thread switches
326 classes in the system (including system classes)
1381 dynamic objects allocated (56212 bytes)
13 garbage collections (35852 bytes collected)
Total heap size 500000 bytes (currently 459160 bytes free)
Reply With Quote

#8 Old 2003-12-02, 11:12

Join Date: Jul 2003
Posts: 1,094
Location: Finland, Tampere
doctordwarf
Offline
Super Contributor
koolgi
Knowing your project settings might help you find the workaround, but does not really help to identify the problem.

Check whether your file is actually put to the JAR file and that it is at the expected path.

As far as I know JBuilder can also run projects without packaging JAR, but using "classes" directory (if emulator supports this). If you use this way, check that your file is copied to the "classes" dir and to the appropriate subdirectory
Reply With Quote

#9 Old i have solved it - 2003-12-04, 03:24

Join Date: Aug 2003
Posts: 9
koolgi
Offline
Registered User
rename the file *.* to *.properties, the JB9 can recognise the files, you can read the outer files.

to : cn.dog.blackdog

the jbuilder can not run the PushPuzzle Game in game.jpx, because jb9 donot recognise the file like screen.1, but if you use Sun J2meWTK's simulator ,the game will be run normally!

In the end, thank you everyone who helped me, let's to share it :-)
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia