Class FileIO
java.lang.Object
co.ankatech.ankasecure.sdk.util.FileIO
Centralised UTF-8 file I/O utility for the ANKASecure SDK.
All SDK components must use this class instead of java.nio.file.Files
directly. At runtime the JVM selects the best implementation available:
- Java 17 / Android ART – loads the portable
BaseImpl
(byte-code 17) that relies only on classic streams. - Java 21+ – the class-loader prefers the optimised
variant located in
META-INF/versions/21/
which delegates toFiles.readString
/Files.writeString
.
The public API remains stable, giving you total flexibility to swap or enhance implementations in future releases without touching client code.
- Since:
- 1.0
- Author:
- ANKASecure Team
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Reads the entire file as UTF-8 and trims trailing line breaks exactly likeString.trim()
.static void
Writes the text to the given path using UTF-8, replacing any existing file (same semantics asStandardOpenOption.TRUNCATE_EXISTING
).
-
Method Details
-
readUtf8
Reads the entire file as UTF-8 and trims trailing line breaks exactly likeString.trim()
.- Parameters:
path
- the file to read (non-null, must exist)- Returns:
- file contents (never
null
) - Throws:
IOException
- if an I/O error occurs
-
writeUtf8
Writes the text to the given path using UTF-8, replacing any existing file (same semantics asStandardOpenOption.TRUNCATE_EXISTING
).- Parameters:
path
- destination path (non-null)text
- UTF-8 content to write (non-null)- Throws:
IOException
- if an I/O error occurs
-