public class Main
extends Object
Constructor and Description |
---|
Main() |
Modifier and Type | Method and Description |
---|---|
static void |
main(String[] args)
The primary entry point for the program.
|
private static void |
printHelp()
Prints a help message to the screen and exists the program.
|
public static void main(String[] args)
The primary entry point for the program. This program assumes at least two, most commonly three program arguments. The first argument is always the file to load, and it must be a CSV file. The second argument is the term information in the format of {YEAR}{TERMID}0, and the third optional argument is the file name in which to save the output.
If only two arguments are provided
the stats for that term will be printed out to
the terminal (System.out.println) using DemographicDataWriter.writeToScreen(Data)
.
If three arguments are provided, the
method assumes to write the output in HTML format
to a file based on name provided in the argument using
DemographicDataWriter.writeToHtml(String, Data)
Example command line execution:
> java Main STEM_Diversity_Data.csv 202090
The above example, instructs the program to read in STEM_Diversity_Data.csv and prints out to the screen the stats for term Fall 2020. Students: As this is the first time seeing a command line, the > sign is shows the 'terminal' prompt. Java is the program that loads the Main class you wrote. STEM_Diversity_Data.csv and 202090 are the program arguments, stored in args[0] and args[1] respectively.
For running in IntelliJ, you go to the 'run-configuration' settings (the drop down near the run button in the top bar, is one way to find them) - and add the parts after the Main to the program arguments box in the configuration. Talk with a TA right away to get that part figured out!
Below is a three argument example.
> java Main STEM_Diversity_Data.csv 202090 Fall20.html
The above example, saves an HTML table to the file Fall20.html. Students: it is possible to open the file in your browser to see how it looks, your IDE to see the content of the file.
If more than three arguments are provided, the additional arguments
are ignored. If less than three arguments are provided,
the program prints a help message using printHelp()
and exists.
args
- 2-3 need to be passed in for the program to work properly.Data.loadData(String)
,
DemographicDataWriter.writeToScreen(Data)
,
DemographicDataWriter.writeToHtml(String, Data)
private static void printHelp()
Invalid number of arguments. Input File and term required, output file optional, but required for HTML output. Examples: > java Main STEM_Diversity_Data.csv 202090 > java Main STEM_Diversity_Data.csv 202090 Fall20.html