wood burning stoves 2.0*
The moose likes Flex and the fly likes File Reading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Flex
Bookmark "File Reading" Watch "File Reading" New topic
Author

File Reading

Booma Devi
Ranch Hand

Joined: Nov 02, 2011
Posts: 61
Hi All,

Can anyone please help me how to read the properties file at runtime in flex?

I have created the .properties file outside of src folder and i used the ResourceManager.getInstance syntax...

In my machine code is working fine without anyerror.. If i run it on another one's machine i am getting an error "cannot read local resource file"..

Is there any possibilities of reading properties file at runtime...
Praveen Kumar M K
Ranch Hand

Joined: Jul 03, 2011
Posts: 256
Have you used full path or relative?
Booma Devi
Ranch Hand

Joined: Nov 02, 2011
Posts: 61
Hi Praveen,

Thanks for your reply.. I used URL loader class for reading text file at runtime... Now its working fine in my machine as well as other's machine.. I have setup my file path to trusted local settings..
Praveen Kumar M K
Ranch Hand

Joined: Jul 03, 2011
Posts: 256
Great! You could still use Resource manager, but the properties file has to be part of the resource bundle...
Booma Devi
Ranch Hand

Joined: Nov 02, 2011
Posts: 61
I have tried to read the properties file using resource manager.. But it worked only when the property file located outside of src folder...

Is it possible to read the property file at runtime? (property file should be present inside the src/properties/resource.properties)

If so, can you please give me a simple program for this...
Praveen Kumar M K
Ranch Hand

Joined: Jul 03, 2011
Posts: 256
are you talking about flex source folder or java (back end) src folder?
Booma Devi
Ranch Hand

Joined: Nov 02, 2011
Posts: 61
I am talking about flex/src folder..

Praveen Kumar M K
Ranch Hand

Joined: Jul 03, 2011
Posts: 256
Okay, have a look at this link - http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7f3c.html

In general if you need to use properties file, it would be better to create bundles. From the link you can see that the below are the steps to accomplish our task.

1) Create property files.
2) Include the names of the created property files under the bundle list.
3) Then include the bundle list in the Flex compiler arguments.
4) Then use them from Resource manager.

In case you want a conventional Property reader sort of functionality, you could use the url class loader and give full path.


Booma Devi
Ranch Hand

Joined: Nov 02, 2011
Posts: 61
Thank you so much....But, if we give the bundle list in the compiler arguments list, each time SWF will be generated. I think, URLLoader is the better one.. Thanks for spending your time.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Reading
 
Similar Threads
What is this Properties File?
Is is possible to read values from a properties file but have those variables be static?
Reading a properties file using BufferdInputStream
how to access an external file into a web application
JWS and properties file