title: Get the highest numeric file name(as int) from directory - Java
body: <p>Given a <code>File dir</code> I need to find the highest numeric file name(if any exist)</p>
  
  <p>My approach:</p>
  
  <pre><code>// get the highest numeric file name(as int) from given directory
  public static final int getHighestNumericFileName(File dir) {
      int result = -1;
  
      for (File f : dir.listFiles()) {
          String name = f.getName();
          name = name.substring(0, name.indexOf('.'));
          if (StringUtils.isNumeric(name)) {
              int val = Integer.parseInt(name);
              if (val &gt; result)
                  result = val;
          }
      }
  
      return result;
  }
  </code></pre>
  
  <p>Considering the file count in the folder can get quite large(300k+) my concern is performance related.</p>
  
  <p><strong>Is this at all an acceptable solution? And is there a better way?</strong></p>