public static String readString() throws Exception {
     String res="";
     boolean nosuc = true;//false;
     while (nosuc) {
         try {
             res = bred.readLine();
             nosuc = false;
         } catch (IOException e) {
             writeMessage("Произошла ошибка при попытке ввода текста. Попробуйте еще раз.");
             nosuc = true;
         }
     }
     return res;
 }

 public static int readInt() throws Exception {
     while (true) {
         try {
             return Integer.parseInt(readString());
         } catch (NumberFormatException e) {
             writeMessage("Произошла ошибка при попытке ввода числа. Попробуйте еще раз.");
         }
     }
 }