java.lang.Object
io.helidon.config.FileSourceHelper
Utilities for file-related source classes.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Data and digest of a file. -
Method Summary
Modifier and TypeMethodDescriptionstatic Optional
<byte[]> Returns an MD5 digest of the specified file or null if the file cannot be read.static boolean
isModified
(Path filePath, byte[] digest) Check if a file on the file system is changed, as compared to the digest provided.static boolean
isModified
(Path filePath, Instant stamp) Check if a file on the file system is changed based on its last modification timestamp.lastModifiedTime
(Path path) Returns the last modified time of the given file or directory.readDataAndDigest
(Path filePath) Read data and its digest in the same go.static String
safeReadContent
(Path path) Reads the content of the specified file.
-
Method Details
-
lastModifiedTime
Returns the last modified time of the given file or directory.- Parameters:
path
- a file or directory- Returns:
- the last modified time
-
safeReadContent
Reads the content of the specified file.The file is locked before the reading and the lock is released immediately after the reading.
An expected encoding is UTF-8.
- Parameters:
path
- a path to the file- Returns:
- a content of the file
-
digest
Returns an MD5 digest of the specified file or null if the file cannot be read.The file is locked before the reading and the lock is released immediately after the reading.
- Parameters:
path
- a path to the file- Returns:
- an MD5 digest of the file or null if the file cannot be read
-
isModified
Check if a file on the file system is changed, as compared to the digest provided.- Parameters:
filePath
- path of the filedigest
- digest of the file- Returns:
true
if the file exists and has the same digest,false
otherwise
-
isModified
Check if a file on the file system is changed based on its last modification timestamp.- Parameters:
filePath
- path of the filestamp
- last modification stamp- Returns:
true
if the file exists and has the same last modification timestamp,false
otherwise
-
readDataAndDigest
Read data and its digest in the same go.- Parameters:
filePath
- path to load data from- Returns:
- data and its digest, or empty if file does not exist
-