title: What IOException do i use for FileWriter
body: <pre><code>import java.io.BufferedInputStream;
  import java.io.DataInputStream;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.FileReader;
  import java.io.IOException;
  import java.io.FileWriter;
  import java.io.BufferedWriter;
  import java.io.BufferedReader;
  
  /**
  * This program reads a text file line by line and print to the console. It uses
  * FileOutputStream to read the file.
  *
  */
  public class Writer {
  
  public static void main(String[] args) {
  
  File file = new File("C:\\Users\\McIntosh\\Documents\\APCS_Contest\\randomGenProb1.txt");
  File file2 = new File("C:\\Users\\McIntosh\\Documents\\APCS_Contest\\Letters.txt");
  FileWriter fw = new FileWriter(file2);
  BufferedWriter bw = new BufferedWriter(fw);
  FileInputStream fis = null;
  BufferedInputStream bis = null;
  DataInputStream dis = null;
  
  try 
  {
  fis = new FileInputStream(file);
  
  // Here BufferedInputStream is added for fast reading.
  bis = new BufferedInputStream(fis);
  dis = new DataInputStream(bis);
  
  int count = 0;
  String str;
  char temp;
  String abc = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  char[] list = abc.toCharArray();
  // dis.available() returns 0 if the file does not have more lines.
  while (dis.available() != 0) 
  {
    str = dis.readLine();
    for(int x=0;x&lt;str.length()-1;x++)
    {
      for(int y=0;y&lt;list.length;y++)
      {
        temp = str.charAt(x);
        if(temp==(list[y]))
        {
          bw.write(temp);
          count++;
        }
      }
    }
  }
  System.out.println(count+" Chars found, and added");
  System.out.println("Finished! Chars added to file: " + file2);
  
  // dispose all the resources after using them.
  fis.close();
  bis.close();
  dis.close();
  bw.flush();
  bw.close();
  fw.close();
  
  } 
   catch (FileNotFoundException e) 
    {
     e.printStackTrace();
    } 
   catch (IOException e) 
    {
     e.printStackTrace();
    }
  }
  } 
  </code></pre>
  
  <p>I keep getting the error:</p>
  
  <pre><code>Error: unreported exception java.io.IOException; must be caught or declared to be     thrown
  </code></pre>
  
  <p>I'm trying to write into the file from strings from another file. I am taking info in from 2 different files and writing into one but, reading in from another. My nested for loop basically goes through and sees if the substring from the first file is a letter from the alphabet, and if it is it goes and adds it to the second file by using the write() method. It counts up how many chars at writes and then system out prints it. I just don't know what exception to add. Thank you so much any help is very appreciated!!</p>