A simple and performant filesystem API. The syntax is easy and consistent across all language/platform implementations. Available for the following: Java, Android, C#, .NET Android, Python, TypeScript/JavaScript.
Published under MIT License
- Abstract file system API with common file operations: create, delete, read, write, list, copy, move, etc
- Abstract Virtual drive with support for parallel batch import/export/delete/search file operations.
- Java (Local Read/Write)
- C# (Local Read/Write .NET 8+, no support for UWP Windows Storage, no support for IsolatedStorage)
- Android: (Supports internal and external SD cards with Android Storage Framework)
- .NET Android: (Supports internal and external SD cards with Android Storage Framework)
- Python (Local files Read/Write)
- TypeScript/JavaScript (supports node.js, browser FileSystemHandle API, and limited virtual localStorage)
- Http (Read-Only, supports Basic Auth)
- WebService (Read/Write, compatible with WebFS, supports Basic Auth)
The API is consistent across all platforms/languages, this example is for Java.
- Get a directory:
// For local directory (read/write):
File dir = new File("C:\my_local_directory");
// For remote HTTP directory (read-only):
HttpFile dir = new HttpFile("https://localhost/my_remote_directory");
// HTTP remote directory with Basic Auth (read-only):
HttpFile dir = new HttpFile("https://localhost/my_remote_directory/", new Credentials("user", "password"));
// Web Service remote directory, compatible with WebFS (read/write):
WSFile dir = new WSFile("/my_remote_directory", "https://localhost:8443", new Credentials("user", "password"));
- List files:
File[] files = dir.listFiles();
- Read a file:
RandomAccessStream stream = file.getInputStream();
stream.seek();
stream.read();
stream.close();
- Write a file:
RandomAccessStream stream = file.getOutputStream();
stream.seek();
stream.write();
stream.close();
- Other operations:
file.getName();
file.getPath();
file.getParent();
file.exists();
file.delete();
file.isFile();
file.isDirectory();
file.copy();
file.move();
...
- To import/copy a file in a directory using multiple threads you can use FileImporter:
FileImporter importer = new FileImporter();
importer.initialize(bufferSize, threads);
FileImportOptions options = new FileImportOptions();
options.onProgressChanged = (pos, len) -> {
System.out.println("bytes copied: " + position);
};
IVirtualFile importFile(fileToImport, dir, options);
importer.close();
- To import files in batches use FileCommander:
FileCommander commander = new FileCommander(new FileImporter(), new FileExporter(), new FileSearcher());
File[] importedFiles = commander.importFiles(files, dir);
commander.close();
- To search for a file by filename:
SearchOptions options = new SearchOptions();
options.onResultFound = (file) -> {
System.out.println("File found: " + file.getPath());
}
File[] files = searcher.search(dir, "filename.txt", options);