Всё генерит верно, крутил в цикле - ошибок не выявил, а валидатор не пускает. Я что то не понимаю.. хэлп
package com.javarush.task.task32.task3204;
import java.io.*;
import java.util.Random;
/*
Генератор паролей
*/
public class Solution {
public static void main(String[] args) throws IOException {
ByteArrayOutputStream password = getPassword();
System.out.println(password.toString());
// for (int i = 0; i < 50; i++) {
// ByteArrayOutputStream password1 = getPassword();
// System.out.println(password1.toString());
// }
}
public static ByteArrayOutputStream getPassword() {
StringBuilder password = new StringBuilder();
for (int i = 0; i < 8; i++) {
password.append(getRandomChar());
}
if (checkСondPassword(password) == false){
getPassword();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream inputStream = new ByteArrayInputStream(password.toString().getBytes());
BufferedInputStream bis = new BufferedInputStream(inputStream);
try{while (bis.available() > 0){
int data = bis.read();
baos.write(data);
}}catch (Exception e){}
return baos;
}
public static char getRandomChar(){
String passChar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random random = new Random();
char ch = passChar.charAt(random.nextInt(passChar.length()));
return ch;
}
public static boolean checkСondPassword(StringBuilder password){
boolean condition = false;
if ((password.toString().matches(".*[A-Z].*"))
&& (password.toString().matches(".*[a-z].*"))
&& (password.toString().matches(".*\\d.*")))
{
condition = true;
}
return condition;
}
}