Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > WebStart: How to read and write config data?

Reply
Thread Tools

WebStart: How to read and write config data?

 
 
Andreas Schmidt
Guest
Posts: n/a
 
      12-09-2003
On Tue, 09 Dec 2003 17:37:55 -0500, Andreas Schmidt <(E-Mail Removed)>
wrote:

> I have a Web Start application. Now I want to add a login and user
> preferences settings. Unfortunately, I don't know how to read and write
> these data. What's the usual way to do it in this case? Open a socket
> connection and read/write a file from the codebase URL? Is that allowed
> to the Web Start application?


I asked this question also in de.comp.lang.java, just in a thread that had
a different original topic, so I decided to post it here. But I got the
answer already there:

Use muffins (analogous to cookies, just for WebStart applications)
see PersistenceService on
http://java.sun.com/products/javaweb...persguide.html

Or write a file into the user dir
String configDir = System.getProperty("user.dir");

Andi
 
Reply With Quote
 
 
 
 
Andreas Schmidt
Guest
Posts: n/a
 
      12-09-2003
I have a Web Start application. Now I want to add a login and user
preferences settings. Unfortunately, I don't know how to read and write
these data. What's the usual way to do it in this case? Open a socket
connection and read/write a file from the codebase URL? Is that allowed to
the Web Start application?

Thanks!
Andi
 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      12-10-2003
Andreas Schmidt <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...

Like applets, you'd be in a sandbox, unless through signing and with
the consent of the user you could write directly to disk.

There is a Preferences class that I believe provides the ability to
write some data while stilling remaining in a sandbox and not
requiring a magic OK from the user (I'm assuming you want to avoid
having to ask the user to allow your application full access to the
system).

As for the initial default data, you can only transport signed jar
files, so no xml or txt files.
What I do is I embed the data in a jar file, and use the class loader
to read it:

InputStream is = getClass().getClassLoader().getResourceAsStream("s omething.xml");

The idea is that if the class itself was able to load from the jar
file, you ought to be able to ask the class loader that loaded that
class to load something else from that same jar file.

You could save an altered version of the xml (or whatever) file to
disk, say, to new File(System.getProperty("user.home"),
"something.xml"); Next time you start you could do a file.isFile() to
see if a version was previously written to disk, and if so, use it,
and if not, use the default one from the jar file using the above
code.



> I have a Web Start application. Now I want to add a login and user
> preferences settings. Unfortunately, I don't know how to read and write
> these data. What's the usual way to do it in this case? Open a socket
> connection and read/write a file from the codebase URL? Is that allowed to
> the Web Start application?
>
> Thanks!
> Andi

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to write Simple JAVA program to read and write from USB serialto use it with Arduino sahm Java 4 10-15-2012 06:24 PM
dll config and web.config and Label Expressions (binding label text to dll config settings) CSharpner ASP .Net 0 04-09-2007 09:00 PM
Read config setting from web.config performance? Hardy Wang ASP .Net 2 07-31-2004 02:39 AM
Web References how to config to read URL from config? Bob ASP .Net Web Services 8 05-05-2004 03:47 AM
Web References how to config to read URL from config? Bob ASP .Net 7 05-05-2004 03:47 AM



Advertisments