You Are Here:

Community: Developer Discussion Boards

#1 Old accessing file problems - 2007-12-13, 00:00

Join Date: Nov 2007
Posts: 13
beyossi
Offline
Registered User
Hi,

I am trying to access a file for reading but it always fails.
Below is the code I am using for that purpose but the returned stream (is) is always null.

String filePath = System.getProperty("fileconn.dir.music");
InputStream is = getClass().getResourceAsStream(filePath+"b.mp3");

I guess I am missing something.
I am using (6270001) S40_SDK_3rd_Edition.
this is the path where b.mp3 resides on the hard disk:
c:\Nokia\Devices\S40_SDK_3rd_Edition\bin\Storage\6270001\C\predefgallery\predefmusic\b.mp3

getProperty returns: "file:///C:/predefgallery/predefmusic/"

but as I said getResourceAsStream always returns null.

Please help with that.

Thanks
Reply With Quote

#2 Old Re: accessing file problems - 2007-12-13, 11:06

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hi,
Check whether you have READ access to the predefmusic folder.Also check manually in the phone whether the b.mp3 phone is good or not.
Thanks
Soku
Reply With Quote

#3 Old Re: accessing file problems - 2007-12-13, 14:15

Join Date: Nov 2003
Posts: 3,641
Location: Bangalore , India
Send a message via Yahoo to balagopalks
balagopalks's Avatar
balagopalks
Offline
Forum Nokia Expert
Hi beyossi! Welcome to Nokia Developer Discussion Boards!! :)

Are you getting any permission message while accessing the MP3 file ?

Since you are trying in the emulator, go to Tools > Preferences > MIDP(Tab) Use the relavant Security domain and make sure that the permissions are set to "Allowed" and restart the emulator.

Also make sure that the MP3 file you are trying with is a valid one.

Are getting any Exceptions ?

Regards
Gopal
Reply With Quote

#4 Old Re: accessing file problems - 2007-12-13, 20:27

Join Date: Nov 2007
Posts: 13
beyossi
Offline
Registered User
Quote:
Originally Posted by balagopalks View Post
Hi beyossi! Welcome to Nokia Developer Discussion Boards!! :)

Are you getting any permission message while accessing the MP3 file ?

Since you are trying in the emulator, go to Tools > Preferences > MIDP(Tab) Use the relavant Security domain and make sure that the permissions are set to "Allowed" and restart the emulator.

Also make sure that the MP3 file you are trying with is a valid one.

Are getting any Exceptions ?

Regards
Gopal
Thanks Soku and Gopal,

The directories have read access.

the b.mp3 file can be played on a media player on my desktop, so I guess it means the file is readable and the file is good.

At the first place the permissions in the MIDP tab were set to the defaults. Then I changed it to allowed as Gopal suggested (it required changing it to trusted) but the behaviour didn't change (i.e. getResourceAsStream still returned null).
Shouldn't I do something with the JAR for making it trusted (is it just a configuration of the emulator)?

Sorry for the silly questions, as it is my first java application (I came from real-time embedded environment using C).

BTW, I am using the eclipse environment.

Do you have any other suggestions?

Thanks
Yossi
Reply With Quote

#5 Old Re: accessing file problems - 2007-12-14, 06:46

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hi,
could you check with another sample file for playing.Also check whether the file is DRM protected or having any other seecurity features.
Thanks
Soku
Reply With Quote

#6 Old Re: accessing file problems - 2007-12-14, 07:01

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hi,
Also check whether the path u specified is correct.
Also have a look at the following links...may be it would be helpful to you..

http://forum.java.sun.com/thread.jsp...sageID=4274220
http://developers.sun.com/mobility/a...ileconnection/

Thanks

Soku
Reply With Quote

#7 Old Re: accessing file problems - 2007-12-14, 11:31

Join Date: Nov 2003
Posts: 3,641
Location: Bangalore , India
Send a message via Yahoo to balagopalks
balagopalks's Avatar
balagopalks
Offline
Forum Nokia Expert
Quote:
Originally Posted by beyossi View Post
Shouldn't I do something with the JAR for making it trusted (is it just a configuration of the emulator)?
To make your MIDlet trusted, you have to Sign it. The settings change that I have suggested is to test in the Emulator like your MIDlet is Signed. Please note that this settings change in the Emulator does not make your app Signed in the real time.

Can you give a try in the real device, does it still returns null ?

Regards
Gopal


MobiQuil.com
An initiative by Developers for Developers.
http://www.mobiquil.com - Alpha - Launched.
Reply With Quote

#8 Old Re: accessing file problems - 2007-12-14, 20:55

Join Date: Nov 2007
Posts: 13
beyossi
Offline
Registered User
Since I am very new to mobile application development I don't know how to see the returned value on the device. Is there a convenient and simple way to do so?

I tried another file, but it didn't realy help.

What is that DRM protection Soku had mentioned?, how can I check that?
What else can be configured for security aspects?

When checking another file I encountered a strange issue: I tried to play the file using the built in media player, but no voice was heard... Then I tried another file named mtmp05116.wav which was probably created in the SDK when I once played it through http connection (it looks like a temporary file the emulator kept on the disk), and it worked. However when I put it in the music directory I still got a null from the getResourceAsStream API.
The 'bad' file can be played on the windows desktop (I encountered few such files) using the windows media player.


Thanks
Reply With Quote

#9 Old Re: accessing file problems - 2007-12-15, 19:47

Join Date: Nov 2003
Posts: 3,641
Location: Bangalore , India
Send a message via Yahoo to balagopalks
balagopalks's Avatar
balagopalks
Offline
Forum Nokia Expert
Quote:
Originally Posted by beyossi View Post
I don't know how to see the returned value on the device. Is there a convenient and simple way to do so?
If your app is Form based, you can append the value to the Form. If using Canvas based app try printing the value using drawString()

I suggest to try your MIDlet using an audio file that comes along with the SDK - Just to make sure that its not the issue with the Audio file.

Regards
Gopal
Reply With Quote

#10 Old Re: accessing file problems - 2007-12-17, 06:05

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hi,
In the developer's guidelines document ( http://developer.sonyericsson.com/ge...do?docId=65067 ) on page 47 there's a list of which JSR-75 operations are permitted on DRM protected files and which aren't. It seems you shouldn't be able to open any InputStreams on them at all - is that what you're seeing?

Thanks
Soku
Reply With Quote

#11 Old Re: accessing file problems - 2007-12-18, 13:24

Join Date: Nov 2007
Posts: 13
beyossi
Offline
Registered User
Thanks for your help.
I also failed to Connect.open the file fore creating a fileConnection, which supposed to be allowed according to what is indicated in the attachement you sent.

I also fail to do it on the device itself.

I will try to play somemore with that.

BTW, is there something in the application build proceddure that may limit me from doing specific actions?

Thanks
Reply With Quote

#12 Old Re: accessing file problems - 2007-12-18, 15:24

Join Date: Nov 2003
Posts: 3,641
Location: Bangalore , India
Send a message via Yahoo to balagopalks
balagopalks's Avatar
balagopalks
Offline
Forum Nokia Expert
Try to copy your file in C:\Nokia\Devices\S40_SDK_3rd_Edition\bin\Storage\Default\C\predefgallery\predefmusic . I mean not inside '6270001\' directory, but to 'Default\'.

Regards
Gopal
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
Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems starting an J2ME app installed via .sis file on 9300i fok Mobile Java Tools & SDKs 1 2006-10-11 22:46
Carbide.vs problems generating AIF file profoundwhispers Symbian Tools & SDKs 3 2006-06-06 09:51
have two problems in import mmp file and without error in build silver_man82 Carbide.c++ IDE and plug-ins 1 2006-06-03 05:18
Problems with CBA resource in 2nd Resource File. colinlawrence Symbian Tools & SDKs 5 2004-02-17 03:47
Accessing data of a stored file lazmous Mobile Java General 2 2003-04-04 16:50

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