regd Java and scripting

Hi

I have a java applet

I have a java object called "Volume" which has certain
attributes like
Name
WWN
Capacity

Now I want to automate the process of creating these
volume objects by reading these properties from some file
say " volume.txt"

For example If have a right click menu option
"import" I could read the properties from "Volume.txt"
and create a new volume object

Also the user could change the values in this file
that is user could edit this file


If I use a simple .txt file for this then I would need
to parse this file which gets complicated

I have looked into creating PDF files from a java application.
But I am not sure there is an easy way to parse these
PDF files or edit them

What could be a good way to do this?

How would I parse the txt files?
Is there any tool available to do this

Please share if there is any other approach

like using a simple scripting language

Thanks













LVL 4
sanjay_thakurAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
tomboshellConnect With a Mentor Commented:
oh ya, here it the link to the java tutorial on the security manager to continue the further accompanying information.  
http://java.sun.com/docs/books/tutorial/essential/system/securityIntro.html
0
 
tomboshellCommented:
If you use the properties object and store the data with matching pairs you could do it quick and easy.  It works like an ini data that most everybody is familar with.  It would only require that your data is in a format like "key=value" then you would make the call to load the data, and could use each set like a hashmap.  

I think the properties object would be best for you.  You are already calling them properties.  Take a look in the java.util package for the class.  The Javadoc gives it straightforward on how to implement it.  

Tom
0
 
CEHJCommented:
I agree with the above. You'll have to store the file containing the properties in the applet's codebase or you won't be allowed to write to it (or read from it for that matter).
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
iartmirkoCommented:
Yes, it's java.util.Properties and then use the load() Method...but this won't work for applets...

I am not really sure why you want to store thes properties in a file...take a DB for saving user input on the server and use these entries for generating your volume objects. You could even use EJBs for the volume objects with CMP...Your applets could connect to them using RMI-IIOP and the Volumes home object would like like a local instance...


For PDF manipulation/generation you can use XML and XSL-FO...it works fine, used it in my last project. For an implementation of XSL-FO and a free processor see http://xml.apache.org/fop/index.html

Have fun!

Mirko
0
 
sanjay_thakurAuthor Commented:
Lets say there is some file on the clients harddrive or A: or anywhere called "Volume.txt"

In the Applet there is a button called "export from"
When the user clicks on this button ,a file chooser is loaded and this file "Volume.txt" is selected

The Applet has to parse this file and find if the values needed to create a new volume object exist.

If the Applet could read and parse this file and find enough information to create a new volume object
It will ; else return an error message


Now the problem is that this "volume.txt" could have any thing.

Even if this file was "Volume.properties" with something like

name:volume
capacity:100 gb

There are problems
This "Volume.properties" will not essentially be in the applets codebase

If this file is not in the applets codebase can the applet still access this file and read from it?

I doubt.

Thus I need to stick with some .txt or .xml file
and then the parsing gets involved


for mirko
I will look into and see if I could use xml

Thanks all of you











0
 
sanjay_thakurAuthor Commented:
Hi all

Is it possible to read the Properties file
if it is not in the Applet's codebase

For example
I create a new Volume Object  with properties
"name==Volume "
"wwn ==192.168.."

now I want to export these values in a file "MyVolume.properties"

now The user can create multiple new volumes
by saying "export" and exporting "MyVolume.properties"

The application will read from "MyVolume.properties"
and create new volume object

Please let me know if this is a possible ?

Thanks all



0
 
CEHJCommented:
>>Is it possible to read the Properties file
if it is not in the Applet's codebase

Yes, but you'll have to sign it. Check out this excellent article:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1215-security.html
0
 
tomboshellCommented:
Yes, the further capabilities would go outside of the applets sandbox.  Applets are designed by default to work ONLY within the web-browser once deployed.  Here is some further information to accompany the above artice: http://java.sun.com/sfaq/

tom
0
 
sanjay_thakurAuthor Commented:
Hi all,

I will try signing the applet and
reading/writing from the properties file


Please have patience.
I will try this and let you know if I am stuck somewhere

Is there is any other workaround to do the same
without signing the applet?

Just a thought!

Thanks all
0
 
sanjay_thakurAuthor Commented:
I have not yet tried signing the applet but I guess
that is not a part of this question

Thanks for all the help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.