title: Removing newline characters from InputStream
body: <p>I like to remove all newline characters (for both \n and \r\n) from an <code>java.io.InputStream</code>, while reading a file, the corresponding method looks like this:</p>
  
  <pre><code>/**
   * @param target {@linkplain File}
   * @return {@linkplain InputStream}
   * @throws Exception
   */
  protected InputStream initInput(final File file)
      throws Exception {
      InputStream stream = null;
      try {
          if (file.isDirectory()) {
              // throw exception
          }
          if (!file.exists()) {
              // throw another exception
          }
          // 
          // *remove newlines here*
          //
          stream = new FileInputStream(file);
  
      } catch (FileNotFoundException e) {
          // throw another exception
      }
      return stream;
  }
  </code></pre>