title: How do I write to a text file given a filename through the command line?
body: <p>I am trying to write to a file with the original path given through the commandline run configurations.  However, I am having a hard time trying to put the pieces together.I am trying to pass the file name through the Report class constructor and then use that to write to the file using a print method.  What am I doing wrong? Sorry, I am very bad at java...</p>
  
  <pre><code>  public static void main(String[] args) throws IOException {
          String roadFilename = args[0];
          String cellNetworkFilename = args[1];
          String imageFilename = args[2];
          String reportFilename = args[3];
  
      Report report = new Report( 
                  new java.io.File(reportFilename)
                  );
          report.add(message);
          report.write();
          cellNetwork.hasCoverage(roadNetwork);
      }
  
  
  public class Report {
      String mess;
      java.util.ArrayList&lt;String&gt; something = new java.util.ArrayList&lt;String&gt;();
      File file;
      private PrintWriter print;
      public Report(File file) {
  
  
          this.file=file;
          // TODO Auto-generated constructor stub
      }
  
      public void add(String message) {
  
          something.add(message);
  
      public void write() {
  
  
          try {
              print = new PrintWriter( 
                      new BufferedWriter(
                              new FileWriter(file)));
              print.println(something);
  
          } catch (IOException e) {
              // TODO Auto-generated catch block
              //          e.printStackTrace();
              System.exit(0);
          }
  </code></pre>