java - I need to make a program that ends input and calculates the total length of the line when I press -


could please explain how make input end when press . without having press enter , calculate length without advanced stuff since beginner.

class userinput//defines class {//class begins     public static void main (string[] args) throws ioexception     {//main method begins         bufferedreader bf = new bufferedreader(newinputstreamreader(system.in));           //tells user program         system.out.println("this program give total number of inputed characters.");           // tells user how end program         system.out.println("to obtain final number of characters, enter .");                 system.out.println("");          //tells user type in characters         system.out.println("enter characters want:");         string input = bf.readline(); //reads user input , initializes input           //initialize , declares variables         int length = 0;         length = length + anything.length();          //outputs total number of characters         system.out.println("the total number of characters input " + length);     }//main method ends }//class ends 

try reading char char using system.in.read(). if doesn't work on platform, see why can't read 1 character @ time system.in?


Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -