karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ravi <ravisekhar...@motivitylabs.com>
Subject Using karaf 4.2.2, From PUTTY console, After entering characters, inconsistency while reading characters.
Date Fri, 26 Apr 2019 12:03:43 GMT
>From PUTTY console, I am entering y or n and reading from my application
using karaf 4.2.2

Reading next byte data, so that, i need to enter two times nn or yy, if
enter name with multiple characters, it is not reading all the characters.
(char)session.getKeyboard().read(); 

Is there any solution to resolve inconsistency of reading characters.

CommandSession session = it is a method parameter.

session.getConsole().printf("Do you wish to continue? (y/n):");
session.getConsole().flush();
boolean result = getYesNoSelection(session);

public boolean getYesNoSelection(CommandSession session) throws IOException
{
   char ch ='\0';
   boolean flag = true;
   while (true) {
       session.getConsole().flush();
       ch = (char)session.getKeyboard().read();
       if (ch == 'Y' || ch == 'y') {
           flag = true;
           session.getConsole().print('y');
           break;
       }
       if (ch == 'N' || ch == 'n') {
           flag = false;
           session.getConsole().print('n');
           break;
       }
   }
   session.getConsole().flush();
   session.getConsole().println();
   session.getConsole().flush();
   return flag;
}



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-Dev-f930721.html

Mime
View raw message