code: public static UfsJournalSnapshot getSnapshot(UfsJournal journal) throws IOException {
      // Checkpoints.
      List<UfsJournalFile> checkpoints = new ArrayList<>();
      UfsStatus[] statuses = journal.getUfs().listStatus(journal.getCheckpointDir().toString());
      if (statuses != null) {
        for (UfsStatus status : statuses) {
          UfsJournalFile file = UfsJournalFile.decodeCheckpointFile(journal, status.getName());
          if (file != null) {
            checkpoints.add(file);
          }
        }
        Collections.sort(checkpoints);
      }
  
      List<UfsJournalFile> logs = new ArrayList<>();
      statuses = journal.getUfs().listStatus(journal.getLogDir().toString());
      if (statuses != null) {
        for (UfsStatus status : statuses) {
          UfsJournalFile file = UfsJournalFile.decodeLogFile(journal, status.getName());
          if (file != null) {
            logs.add(file);
          }
        }
        Collections.sort(logs);
      }
  
      List<UfsJournalFile> tmpCheckpoints = new ArrayList<>();
      statuses = journal.getUfs().listStatus(journal.getTmpDir().toString());
      if (statuses != null) {
        for (UfsStatus status : statuses) {
          tmpCheckpoints.add(UfsJournalFile.decodeTemporaryCheckpointFile(journal, status.getName()));
        }
      }
  
      return new UfsJournalSnapshot(checkpoints, logs, tmpCheckpoints);
    }
docs: Creates a snapshot of the journal.
  
  @param journal the journal
  @return the journal snapshot