title: java error unreported exception java.lang.Exception; must be caught or declared to be thrown
body: <pre><code>import java.io.FileInputStream; 
  
  import org.apache.commons.codec.binary.Base64;
  
  public class Encode 
  {
  
      //file path ex : C:\Program Files\Cordys\Web\reports\I0001180.pdf
      public static String encodeFileStream(String filePath) throws Exception 
      {    
  
          StringBuffer sb=new StringBuffer();
  
          try 
          {
  
              FileInputStream fin = new FileInputStream(filePath);
              //StringBuffer sb=new StringBuffer();
              int lineLength = 72;
              byte[] buf = new byte[lineLength/4*3];
  
              while (true) 
              {
                  int len = fin.read(buf);
                  if (len &lt;= 0)
                  {
                      break;
                  }
                  //new Base64().encode(byte);
                  //sb.append(Base64.encode(buf));
                  //sb.append(Base64.encodeBase64(buf));
  
                  Base64 b = new Base64();
                  sb.append(b.encode(buf)); 
  
                  //return sb.toString();
              }
          }  
  
          catch(Exception e) 
          {
              return e.getMessage();
          }
  
          return sb.toString();
      }
  
      public static void main(String args[])
      {
          String s="";
  
          s=encodeFileStream("E:/CSSDocument/Test.pdf");
      }   
  }
  </code></pre>