title: Java - Generate New Filename for New BufferedImage Files
body: <p>Is it possible to generate a new image name for each image that is processed using the following code (I have highlighted the relevant section)?</p>
  
  <pre><code>public static void makeBinary(File image) { 
  try{
      //Read in original image. 
      BufferedImage inputImg = ImageIO.read(image);
  
      //Obtain width and height of image.
      double image_width = inputImg.getWidth();
      double image_height = inputImg.getHeight();
  
      //New images to draw to.
      BufferedImage bimg = null;
      BufferedImage img = inputImg;
  
      //Draw the new image.      
      bimg = new BufferedImage((int)image_width, (int)image_height, BufferedImage.TYPE_BYTE_BINARY);
      Graphics2D gg = bimg.createGraphics();
      gg.drawImage(img, 0, 0, img.getWidth(null), img.getHeight(null), null);
  
  
  // ************* THIS IS WHERE I AM HAVING DIFFICULTY ***************
  
      //Save new binary (output) image.   
      String temp = "_inverted";
      File fi = new File("images\\" + temp + ".jpg");
      ImageIO.write(bimg, "jpg", fi);
  
  // ******************************************************************
  
  
  }
   catch (Exception e){
      System.out.println(e);
   }
  }
  </code></pre>
  
  <p>I have 300 images, numbered <code>001.jpg</code> - <code>300.jpg</code>, and what I would like is for each new outputted image to be named something along the lines of, <code>binary_001.jpg</code> - <code>binary_300.jpg</code>.</p>
  
  <p>The method that calls <code>makeBinary()</code> is located in another class and is:</p>
  
  <pre><code>public static void listFiles() {
  
      File dir = new File("images");
      File imgList[] = dir.listFiles();
  
      if(dir.isDirectory()){
          for(File img : imgList){
              if(img.isFile()){
                  MakeBinary.makeBinary(img);
                  System.out.println(img + ": processed successfully.");
              }
              else{
                  System.out.println("Directory detected; skipping to next file,");
              }
          }
      }
  }
  </code></pre>
  
  <p>How can I go about achieving this?</p>
  
  <p>Many thanks.</p>