JavaFX: Bringing Rich Experiences To All the Screens Of Your Life

Profile: desktop, common

Overview

Storage provides methods for storing data locally on the client system, even for applications that are running in untrusted execution environment.

Storage areas are isolated on the host platform by the URL that the application comes from. For example, assume an application is hosted by the site http://www.mysite.com. The JavaFX platform shares storage for all JavaFX applications from this domain in shared space. This storage area will appear to have a separate file system from the storage used for any other domain. Each application will have a default storage location that corresponds to the path used on the domain to access the HTML, JAR file, or JNLP file from which the JavaFX script is loaded. That is, if the URL of the JNLP file for the JavaFX application in question is http://www.mysite.com/apps/App1/myApp.jnlp. Creating a file on the platform's storage using the name "myFile.txt" will place the file in the /apps/App1 directory. This file can also be accessed using the full path "/apps/App1/myFile.txt". Realizing that not all applications from a particular domain will want to share data, JavaFX is designed such that data can be isolated from other applications, or shared with them, using the directory structure. If the previous example site also hosts another JavaFX application at http://www.mysite.com/apps/App2, files stored in /apps/App1 are protected from access by App2. Similarly, files stored in /apps/App2 are not accessible by App1. However, if a file is placed into /apps, both App1 and App2 will have access to it. In short, App1 has access to the following directories:

The user of a platform will have the capability to limit storage access on a system-wide, application, or per-file basis. It is also possible for the application itself to limit the size of each file it creates. Writing to a file beyond this limit will trigger an IOException. Specifying a size limit of -1 indicates that the file should be allowed to grow until whatever other limit takes effect.

Data stored using this API remains on the platform until explicitly deleted, whether by using this API or by the platform's user (e.g., when deleting the application).

Example:


 import javafx.io.Storage;
 import javafx.io.Resource;
 import java.io.InputStream;

 var entry = Storage {
    source: "myfile.txt"
 }
 var resource = entry.resource;
 var inputstream = resource.openInputStream();
 // use the input stream
 inputstream.close();
 
The Storage class provides basic functionality of a specific stored resource on the host platform. It also provides the only way to access a resource by full path. Otherwise, a resource can only be obtained from interaction from the user, and the path to the resource will be unknown to the application.

See Also:
Resource

Profile: common

Script Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
public-readavailableBytesLong

Number of bytes available for this application.

public-readtotalBytesLong

Number of bytes alloted for this application.

Variable Summary

accessnametypeCan ReadCan InitCan WriteDefault Valuedescription
public-readresourceResource

The resource to be manipulated.

The resource to be manipulated. Use this object to read or write to the resource, or to get resource-specific data.

 
public-initsourceString

The path to the resource in the persistent storage.

The path to the resource in the persistent storage. This is either a simple filename or an absolute path (starting with "/") to the resource.

 

Inherited Variables

Script Function Summary

public clearAll() : Boolean

Deletes all stored items for this application in the application's default directory.

Deletes all stored items for this application in the application's default directory.

Returns
Boolean
true if successful, false upon error.

Profile: common

 
public list() : java.lang.Object[]

Lists the resources accessible by this application

Lists the resources accessible by this application

Returns
Object[]
A sequence of resource source strings.

Profile: common

 

Function Summary

public clear() : Boolean

Deletes this resource from the platform.

Deletes this resource from the platform.

Returns
Boolean
true if file was deleted successfully, false otherwise
 

Inherited Functions




Spec-Zone.ru - all specs in one place