code: public static String generateSessionId(File logDir) {
          int i = 1;
          String session = "s0001";
          while (new File(logDir, session).exists() && i < 10000) {
              i++;
              session = "s" + Integer.toString(10000 + i).substring(1);
          }
          return session;
      }
docs: Generates a session identifier. The value corresponds to the name of a
  sub-directory (session) in the root test log directory.
  
  @return a session id string ("s0001" by default, unless the session
  sub-directory already exists).