Created
March 29, 2014 23:58
-
-
Save Hoolean/9865035 to your computer and use it in GitHub Desktop.
Command Line File in Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this should be in your main class - more on that later | |
public static void main(String[] args) | |
{ | |
System.out.println(args); | |
/* | |
If user ran: | |
java -jar FuelChecker.jar check diesal | |
Output: (or similar) | |
{"check", "diesal"} | |
*/ | |
if (args.length > 0) | |
{ | |
if (args[0].equalsIgnoreCase("check")) | |
{ | |
// check fuel and stuff | |
} | |
else | |
{ | |
System.out.println("Invalid command! Run the JAR with no arguments to see help."); | |
} | |
} | |
else | |
{ | |
System.out.println("Usage: java -jar FuelChecker.jar check <fuel type>"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment