private static String getPID ( ) { String name = ManagementFactory . getRuntimeMXBean ( ) . getName ( ) ; int index = name . indexOf ( ' ' ) ; if ( index == - 1 ) { return null ; } String pid = name . substring ( 0 , index ) ; if ( ! pid . matches ( "[0-9]+" ) ) { return null ; } return pid ; }
Return the current process ID .