apps/docs/src/content/docs/en/java-sdk/file-system.mdx
File system operations facade for a specific Sandbox.
Provides methods for directory management, file upload/download, metadata inspection, and search/replace operations.
public void createFolder(String path, String mode)
Creates a directory in the Sandbox.
Parameters:
path String - directory pathmode String - POSIX mode (for example 755); defaults to 755 when nullThrows:
io.daytona.sdk.exception.DaytonaException - if creation failspublic void deleteFile(String path)
Deletes a file.
Parameters:
path String - file path to deleteThrows:
io.daytona.sdk.exception.DaytonaException - if deletion failspublic byte[] downloadFile(String remotePath)
Downloads a file into memory.
Parameters:
remotePath String - source file path in the SandboxReturns:
byte[] - file bytes; empty array when no file payload is returnedThrows:
io.daytona.sdk.exception.DaytonaException - if download or local read failspublic InputStream downloadFileStream(String remotePath) throws io.daytona.sdk.exception.DaytonaException
Downloads a single file from the Sandbox as a stream without buffering the entire file
into memory. The returned InputStream can be piped directly to an HTTP response,
written to a file, or processed on the fly.
The caller is responsible for closing the returned stream.
Parameters:
remotePath String - source file path in the SandboxReturns:
InputStream - an InputStream streaming the file contentThrows:
io.daytona.sdk.exception.DaytonaException - if the file does not exist or access is deniedpublic InputStream downloadFileStream(String remotePath, int timeoutSeconds) throws io.daytona.sdk.exception.DaytonaException
Downloads a single file from the Sandbox as a stream without buffering the entire file into memory, with a custom timeout.
The caller is responsible for closing the returned stream.
Parameters:
remotePath String - source file path in the SandboxtimeoutSeconds int - timeout in seconds; 0 means no timeoutReturns:
InputStream - an InputStream streaming the file contentThrows:
io.daytona.sdk.exception.DaytonaException - if the file does not exist or access is deniedpublic InputStream downloadFileStream(String remotePath, DownloadStreamOptions options) throws io.daytona.sdk.exception.DaytonaException
Downloads a single file from the Sandbox as a stream with configurable options.
Parameters:
remotePath String - source file path in the Sandboxoptions DownloadStreamOptions - download options including timeout and progress callbackReturns:
InputStream - an InputStream streaming the file contentThrows:
io.daytona.sdk.exception.DaytonaException - if download failspublic void uploadFile(byte[] content, String remotePath)
Uploads in-memory file content to a Sandbox path.
Parameters:
content byte[] - file bytes; null uploads an empty fileremotePath String - destination file path in the SandboxThrows:
io.daytona.sdk.exception.DaytonaException - if upload failspublic void uploadFileStream(InputStream source, String remotePath, UploadStreamOptions options)
Streams an upload to a Sandbox path without buffering the source. The bytes are piped through a progress-counting wrapper directly into a streaming multipart request, so heap usage stays flat regardless of source size.
Parameters:
source InputStream - the data source; the caller retains ownership and is responsible for closing itremotePath String - destination file path in the Sandboxoptions UploadStreamOptions - upload options including timeout, cancellation, and progress callbackThrows:
io.daytona.sdk.exception.DaytonaException - if upload failspublic void uploadFileStream(InputStream source, String remotePath)
Convenience overload using default options.
Parameters:
source InputStream -remotePath String -public List<FileInfo> listFiles(String path)
Lists files and directories under a path.
Parameters:
path String - directory pathReturns:
List\<FileInfo\> - file metadata entriesThrows:
io.daytona.sdk.exception.DaytonaException - if listing failspublic FileInfo getFileDetails(String path)
Returns metadata for a single file or directory.
Parameters:
path String - file or directory pathReturns:
FileInfo - metadata recordThrows:
io.daytona.sdk.exception.DaytonaException - if lookup failspublic List<Map<String, Object>> findFiles(String path, String pattern)
Searches files by content pattern.
Parameters:
path String - root directory to searchpattern String - text pattern to findReturns:
List\<Map\<String, Object\>\> - list of matches containing file, line, and contentThrows:
io.daytona.sdk.exception.DaytonaException - if the search request failspublic Map<String, Object> searchFiles(String path, String pattern)
Searches files by file-name pattern.
Parameters:
path String - root directory to searchpattern String - file-name patternReturns:
Map\<String, Object\> - result map containing filesThrows:
io.daytona.sdk.exception.DaytonaException - if the search request failspublic void replaceInFiles(List<String> files, String pattern, String newValue)
Performs in-place replacement in multiple files.
Parameters:
files List<String> - files to processpattern String - pattern to replacenewValue String - replacement textThrows:
io.daytona.sdk.exception.DaytonaException - if replacement failspublic void moveFiles(String source, String destination)
Moves or renames a file or directory.
Parameters:
source String - source pathdestination String - destination pathThrows:
io.daytona.sdk.exception.DaytonaException - if move fails