public static File getWALFile(File dir, long versionId) throws FileNotFoundException {
    String filePrefix = WAL_FILE_PREFIX + versionId + FILE_NAME_SEPARATOR;
    File[] files =
        dir.listFiles((d, name) -> walFilenameFilter(d, name) && name.startsWith(filePrefix));
    if (files == null || files.length != 1) {
      throw new FileNotFoundException(
          String.format(
              "Fail to get wal file by versionId=%s and files=%s.",
              versionId, Arrays.toString(files)));
    }
    return files[0];
  }
Get the .wal file starts with the specified version id in the directory.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/utils/WALFileUtils.java