title: Java: write to multiple files using a BufferedWriter array (or another way?)
body: <p>Instead of having 15 BufferedWriters, is there a way that I could write to 15 different files using an array?   </p>
  
  <pre><code>public static void main (String [] args) {
      try {
          BufferedReader br = new BufferedReader(new FileReader("" ));
          BufferedWriter bw = new BufferedWriter(new FileWriter( "1occurrence.txt"));
  
          HashMap&lt;String,Integer&gt; hash = new HashMap&lt;String,Integer&gt;();
  
  
   while ((line= br.readLine() ) != null) {
  
      if ( !hash.containsKey(genesym)) {
                  hash.put (genesym, 1);
                  int count=0;
                  bw.write(line + "\n");
              }
  
              else  {
                  count = hash.get(genesym);
                  if (count==1) {
                      bw2.write(line + "\n");
                      count++;
                  }
                  else if (count==2) {
                      bw3.write(line + "\n");
                      count++;
                  }
  </code></pre>
  
  <p>Then I have 12 more 'else if' statements to write to up to 15 different files.
  Something like </p>
  
  <pre><code>BufferedWriter [] bw = new BufferedWriter[15];
  
  for (int i=0; i&lt;15; i++) {
  
      array[i] = new BufferedWriter(); }
  </code></pre>
  
  <p>I realize this syntax is highly incorrect, but this is the best way I can explain it.</p>
  
  <p>Thanks for the help!</p>