File System support
CheerpJ provides full filesystem support for converted Java applications.
Read only and read/write filesystems are exposed in Java and can be used to read, write and manipulate files as normally when running on a JVM.
Note: CheerpJ provides access to a virtualized filesystem, which does not correspond to the local computer. Accessing local files from the browser it’s forbidden for security reasons.
File Systems in CheerpJ
CheerpJ implements three main filesystem concepts:
- A read-only, HTTP-based filesystem
- A read/write, IndexedDB-based, persistent filesystem
- A read-only, memory based filesystem
CheerpJ filesystems are implemented as UNIX-style virtual filesystems with multiple mount points. The default mount points are defined as follows:
|An HTTP-based read-only filesystem, used to access JARs and data from your local server|
|An IndexedDB-based, persistent read-write file system|
|Another HTTP-based read-only filesystem, pointing to the CheerpJ runtime|
/app/ mount point
The /app/ mount point corresponds to a virtual read-only, HTTP-based filesystem.
/app/ is used to access JAR files and data from your local server.
/app/ directory is virtual, and only exists inside of CheerpJ. It is required to distinguish files from the local server from runtime files and files stored in the browser database.
/app/ directory refers to the root of your web server. So, assuming that your web server is available at
http://127.0.0.1:8080/, here are some example file mappings:
/files/ mount point
/files/ mount point corresponds to a virtual read-write, IndexedDB-based filesystem.
/files/ is used to store persistent data on the browser client.
/files/ directory is a virtual concept used by CheerpJ to store and refer to files.
/str/ mount point
cheerpjAddStringFile API. Example:
You can access this data from Java, for example:
Uint8Arrays may be useful to provide binary data to the Java application, for example a user selected file coming from an HTML5
<input type="file"> tag.