Class FileIO

java.lang.Object
co.ankatech.ankasecure.sdk.util.FileIO

public final class FileIO extends Object
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 to Files.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 Details

    • readUtf8

      public static String readUtf8(Path path) throws IOException
      Reads the entire file as UTF-8 and trims trailing line breaks exactly like String.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

      public static void writeUtf8(Path path, String text) throws IOException
      Writes the text to the given path using UTF-8, replacing any existing file (same semantics as StandardOpenOption.TRUNCATE_EXISTING).
      Parameters:
      path - destination path (non-null)
      text - UTF-8 content to write (non-null)
      Throws:
      IOException - if an I/O error occurs