F The Resource class—this class represents the stored item. As of version 1.2 of the
SDK, a resource instance is mapped to an actual file in the user's local file system.
You can use function resource.openOutputStream() to obtain an instance of
OutputStream to write the data stream locally. The code uses the resource.
openInputStream() function to get a reference to an InputStream object that
is used to read the data from local storage.
As of JavaFX version 1.2.x, the Storage API exposes raw streams, ( java.
io.InputStream and java.io.OutputStream ) for IO operations.
Unfortunately, there are no JavaFX script syntax or API abstractions of the
java.io.* classes. Therefore, you have to be familiar with low-level
Java IO operations to read or write files.
The Storage class provides several functions to manage the resources in which you may be
F list():Object —a script-level function that lists all of the resources that can be
accessed (or was created) by this application on the user's local file system
F clearAll():Boolean —this function deletes all of the saved resources from the
F clear():Boolean —this function is used to delete the resource associated with the
instance of the Storage object
The Resource class exposes some useful properties of which you should be aware as well:
F length:Long —this property returns the size of the resource in bytes
F maxLength:Long —this is the maximum size that can be stored on a user's local
F name:String —the name of the resource at its stored location
F readable:Boolean/writeable:Boolean —these flags indicate the accessibility
of the resource
When a user accesses your application as an applet, or runs it as a Java Web Start (see
Chapter 7 , Deployment and Integration) from the Web, JavaFX allows the application to
store data locally even when the application runs as untrusted. The Storage API creates
a sandbox storage area for each running application. This approach is similar to browser
cookies (amusingly, in JavaFX, it's called a muffin). Each application is given its own, isolated
storage space. By default, an application is reserved 1MB of storage. Total storage with each
resource having a default size of 8KB (these defaults can be configured; see Local storage