Using JNLP filecontents

D

David Lamb

I'm designing some software to live within the restrictions of the JNLP
sandbox. I understand how to use the various interfaces to create an
open file dialog, read the contents, create a save file dialog, and
write the contents -- the stuff corresponding to conventional Open and
Save As menu items.

Now I'm trying to figure out how to do a "Reopen" dialog -- discard the
current internal data and reread the document from scratch. Is there
anyone who has used these facilities enough to be able to answer the
following more detailed version of my question?

The FileOpenService openFileDialog and saveFileDialog methods each
return a FileContents object, which provides a getInputStream operation
for reading the file from persistent storage, and a getOutputStream for
writing. If I close the input stream after reading, then call
getInputStream again, will that give me a new input stream for the same
FileContents so I can do a reread?
 
J

John B. Matthews

David Lamb said:
I'm designing some software to live within the restrictions of the
JNLP sandbox. I understand how to use the various interfaces to
create an open file dialog, read the contents, create a save file
dialog, and write the contents -- the stuff corresponding to
conventional Open and Save As menu items.

Now I'm trying to figure out how to do a "Reopen" dialog -- discard
the current internal data and reread the document from scratch. Is
there anyone who has used these facilities enough to be able to
answer the following more detailed version of my question?

The FileOpenService openFileDialog and saveFileDialog methods each
return a FileContents object, which provides a getInputStream
operation for reading the file from persistent storage, and a
getOutputStream for writing. If I close the input stream after
reading, then call getInputStream again, will that give me a new
input stream for the same FileContents so I can do a reread?

If you haven't already looked at this, it might be useful:

<http://pscode.org/jws/>

As getInputStream() returns a java.io.InputStream, you might be able to
use mark() and reset().
 
D

David Lamb

If you haven't already looked at this, it might be useful:
<http://pscode.org/jws/>

Thanks for the link. It mentions the ExtendedService for a somewhat
different problem, so I'll investigate that.
As getInputStream() returns a java.io.InputStream, you might be able to
use mark() and reset().

Maybe, but InputStreams aren't guaranteed to provide mark/reset.
Perhaps FileContents always would, but I haven't seen a written guarantee.
 
J

John B. Matthews

David Lamb said:
Thanks for the link. It mentions the ExtendedService for a somewhat
different problem, so I'll investigate that.


Maybe, but InputStreams aren't guaranteed to provide mark/reset.
Perhaps FileContents always would, but I haven't seen a written
guarantee.

Good point. Would it suffice to know at run time via markSupported()?
 
D

David Lamb

Good point. Would it suffice to know at run time via markSupported()?

Yes. I'm trying to set things up so that if the application is invoked
in the sandbox it does as much as it can, but does more if invoked as an
application or via JWS with AllPermissions. So I'm content to check at
runtime and disable the Reload menu item if it can't be implemented
directly (without a Close+new Open).

Still, it would be nice to provide as much functionality under JNLP as
possible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,144
Latest member
KetoBaseReviews
Top