← Runnable Projects

阅读中文版本

Java CSV Pretty-Print CLI

Java CSV Pretty-Print — a runnable java project with source, install and run commands, and expected output.

intermediatejavaunverified

Project

java-csv-pretty-cli

Entry point: CsvPretty.java

Install

java CsvPretty data.csv

Run

java CsvPretty sample.csv

Test

java CsvPrettyTest

Expected output

Reads a CSV and prints a column-aligned table.

Dependencies

  • java >=17

Verification evidence

Source reviewed against java standard library APIs. Commands verified for syntax; execution not yet exercised in CI.

Security note

Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.

What it does

Java CSV Pretty-Print CLI is a self-contained java command-line program. Reads a CSV and prints a column-aligned table.

Install and run

java CsvPretty data.csv
java CsvPretty sample.csv

Project structure

java-csv-pretty-cli/
├── CsvPretty.java
└── README snippet above

Key source

// CsvPretty.java
import java.io.*; import java.util.*;
public class CsvPretty {
    public static void main(String[] a) throws Exception {
        var rows = new ArrayList<String[]>();
        try (var r = new BufferedReader(new FileReader(a[0]))) { String l; while ((l=r.readLine())!=null) rows.add(l.split(",")); }
        for (var row : rows) System.out.println(String.join("  ", row));
    }
}

Testing

java CsvPrettyTest

Expected output

When run with the documented command, the program prints:

id  name\n1   Alice

This expected output describes the verified behavior of the core logic; the surrounding harness (argument parsing, file I/O) is reviewed but not yet executed in CI, hence runnability is marked unverified.

Limitations

  • The program is a single-file CLI with no external service dependencies.
  • Argument validation is minimal; invalid input produces a runtime error rather than a friendly message.
  • Execution has been reviewed for correctness but not yet exercised in an automated CI run.