I'm trying to figure out how to pass two files (input.txt and output.txt) as arguments to my main method, read the input file, pass it to a recursive method, then write the mutated string to an output file. I've never worked with commandline arguments before, so I'm not sure how to go about making it work. Here's the code so far:
public static void main(String[] args)
{
ArrayList<String> fileInput = new ArrayList<String>();//ArrayList to hold data from input file
File file = new File(args[0]);
try
{
Scanner scan = new Scanner(new File(args[0]));
FileInputStream readFile = new FileInputStream("input.txt"); // readFile passed from args[0]; args[0] is the argument passed as a string that is held at the 0 index of the args array
fileInput.add(file); //red error line under Add
}
catch(IOException e)
{
e.printStackTrace();
System.exit(0);
}
ArrayList<String> strArray = new ArrayList<String>();
String s;
for(int i = 0; i < file.length() ; i++) //int i = 0; length of stored string data object; i++)
{
//recursiveMarkUp is a string type
strArray.add(file.recursiveMarkUp());//call the markup method and save to an array so we can print to the output file later
//line to print output to output.txt
}
}