title: Getting Error : Unreachable catch block for FileNotFoundException. This exception is never thrown from the try statement body
body: <p>I have wrote a piece of code for returning image whenever I hit the url with specific image name, and if image not found just return the error image.</p>
  
  <pre><code>@GET
  @Path("/getImage/{param1}")
  @Produces({ "image/png", "image/jpeg", "image/gif", "image/jpg" })
  public Response getProductimage(@PathParam("param1") String recievedData) {
  
  
      File file = null;
      try {
          file = new File("C:/Users/Gaurav/Desktop/AppData/"
                  + recievedData);
  
      } catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          file = new File("C:/Users/Gaurav/Desktop/AppData/error.png");
  
          System.out.println(e.getMessage());
      }
  
      return Response.ok(file).build();
  
  }
  </code></pre>
  
  <p>Still I'm getting this error when trying to hit for wrong image</p>
  
  <pre><code>SEVERE: Servlet.service() for servlet [Jersey RESTful Application] in context with path [/WebServices] threw exception [org.glassfish.jersey.server.ContainerException: java.io.FileNotFoundException: C:\Users\Gaurav\Desktop\AppData\average11.png (The system cannot find the file specified)] with root cause
  java.io.FileNotFoundException: C:\Users\Gaurav\Desktop\AppData\average.png15 (The system cannot find the file specified)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:131)
      at org.glassfish.jersey.message.internal.FileProvider.writeTo(FileProvider.java:115)
  </code></pre>
  
  <p>Whats wrong in the code?</p>