title: Java 8: Lambda-Streams, Filter by Method with Exception
body: <p>I have a problem trying out the Lambda expressions of Java 8.
  Usually it works fine, but now I have methods that throw <code>IOException</code>'s. 
  It's best if you look at the following code:</p>
  
  <pre><code>class Bank{
      ....
      public Set&lt;String&gt; getActiveAccountNumbers() throws IOException {
          Stream&lt;Account&gt; s =  accounts.values().stream();
          s = s.filter(a -&gt; a.isActive());
          Stream&lt;String&gt; ss = s.map(a -&gt; a.getNumber());
          return ss.collect(Collectors.toSet());
      }
      ....
  }
  
  interface Account{
      ....
      boolean isActive() throws IOException;
      String getNumber() throws IOException;
      ....
  }
  </code></pre>
  
  <p>The problem is, it doesn't compile, because I have to catch the possible exceptions of the isActive- and the getNumber-Methods. But even if I explicitly use a try-catch-Block like below, it still doesn't compile because I don't catch the Exception. So either there is a bug in JDK, or I don't know how to catch these Exceptions.</p>
  
  <pre><code>class Bank{
      ....
      //Doesn't compile either
      public Set&lt;String&gt; getActiveAccountNumbers() throws IOException {
          try{
              Stream&lt;Account&gt; s =  accounts.values().stream();
              s = s.filter(a -&gt; a.isActive());
              Stream&lt;String&gt; ss = s.map(a -&gt; a.getNumber());
              return ss.collect(Collectors.toSet());
          }catch(IOException ex){
          }
      }
      ....
  }
  </code></pre>
  
  <p>How can I get it work? Can someone hint me to the right solution?</p>