private void upgradeIfNeeded ( File oldPidGenDir ) throws IOException { if ( oldPidGenDir != null && oldPidGenDir . isDirectory ( ) ) { String [ ] names = oldPidGenDir . list ( ) ; Arrays . sort ( names ) ; if ( names . length > 0 ) { BufferedReader in = new BufferedReader ( new InputStreamReader ( new FileInputStream ( new File ( oldPidGenDir , names [ names . length - 1 ] ) ) ) ) ; String lastLine = null ; String line ; while ( ( line = in . readLine ( ) ) != null ) { lastLine = line ; } in . close ( ) ; if ( lastLine != null ) { String [ ] parts = lastLine . split ( "|" ) ; if ( parts . length == 2 ) { neverGeneratePID ( parts [ 0 ] ) ; } } } } }
Read the highest value from the old pidGen directory if it exists and ensure it is never used .