A lightweight, zero-dependency Java utility for parsing command-line style strings into parameters, with intelligent handling of quoted strings.
- Simple Parsing: Splits strings into parameters while preserving quoted text as single tokens.
- Configurable Flags: Supports various parsing modes (condense whitespace, ignore quotes, trim quoted params).
- Low Overhead: No external dependencies, minimal memory footprint.
- Thread-Safe: Immutable instances are thread-safe; mutable via setters.
ParamLiner parser = new ParamLiner();
String[] params = parser.parse("command param1 \"param2 with spaces\" param3");
// Output: ["command", "param1", "param2 with spaces", "param3"]ParamLiner parser = new ParamLiner(ParamLiner.CONDENSE_ALL | ParamLiner.TRIM_ALL_ANSWERS);
String[] params = parser.parse("command \" param2 with spaces \" param3");
// Output: ["command", "param2 with spaces", "param3"]CONDENSE_ALL: Condense all whitespace before parsing.IGNORE_QUOTES: Treat quotes as regular characters.TRIM_ALL_ANSWERS: Trim whitespace from quoted parameters.
- Java JDK 17 or higher
- Apache Maven (optional, but recommended)
The easiest way to get started is to clone the repository and build it using Maven.
git clone https://github.com/zarterstein/ParamLiner.git
cd ParamLiner
mvn clean installSince ParamLiner has no external dependencies, you can also simply copy ParamLiner.java directly into your project's source tree.
mvn clean compilemvn testmvn compile exec:java -Dexec.mainClass="com.zarterstein.ParamLiner.ParamLinerTestConsole" -Dexec.classpathScope="test"If you prefer not to use Maven:
javac src/main/java/com/zarterstein/ParamLiner/ParamLiner.java -d target/classesjavac -cp target/classes src/test/java/com/zarterstein/ParamLiner/ParamLinerTestConsole.java -d target/test-classes
java -cp target/classes;target/test-classes com.zarterstein.ParamLiner.ParamLinerTestConsoleSee Javadocs in the source code for detailed method documentation.
Contributions welcome! Please submit issues or pull requests on GitHub.
- Java code: Human-written
- Javadocs and README: Generated with LLM assistance