code: public static String randomString(int _length) {
          if (_length <= 0) {
              return "";
          }
          Random random = new Random();
          char[] buf = new char[_length];
          for (int idx = 0; idx < buf.length; ++idx)
              buf[idx] = SYMBOLS[random.nextInt(SYMBOLS.length)];
          return new String(buf);
      }
docs: Generate a simple (cryptographic insecure) random string.
  @param _length length of random string
  @return random string or empty string if _length &lt;= 0