title: Drawing Filled Rectangle over a BufferedImage
body: <p>So I am attempting to create an application that can black-out sections of a survey that contains sensitive information.  However I've run into a bit of a problem.</p>
  <p>What I want to do is draw filled black rectangles over a BufferedImage given x, y, width, and height of desired region to black out, then write that new image back to my filesystem.  Here's my code.</p>
  <pre><code>File imageFile = new File(&quot;images/template.jpg&quot;);
  BufferedImage img = ImageIO.read(imageFile);
          
  Graphics2D graph = img.createGraphics();
  graph.setColor(Color.BLACK);
  graph.fill(new Rectangle(x, y, width, height));
  graph.dispose();
          
  ImageIO.write(img, &quot;jpg&quot;, new File(&quot;images/template.jpg&quot;));
  </code></pre>
  <p>For whatever reason the image in the resource doesn't change after this code segment.  Any ideas on what I'm doing wrong?</p>