Link to home
Start Free TrialLog in
Avatar of RgrWalker
RgrWalker

asked on

public static String readLine().........Just a few lines of code that are still giving me problems. Could someone explain these to me?

public static String readLine()...........................Reads it Character by Character from Standard input using Systme.in.read() method
{
StringBuffer sb=new StringBuffer();.................(What is this doing?)
try

{

while(true)

{

char c=(char)System.in.read();

if(c=='\r'||c=='\n' || c==-1 || c==255)...........this line checks for the EOF or newline.

{
break; .......................................This is telling it to go to the end of the program?
}
sb.append(c);..........sb.append(c)  stores the characters

}
}
catch(Exception ex).........................Not sure about this one

{

}

return sb.toString();.....................Also not sure about

}

Avatar of sudhakar_koundinya
sudhakar_koundinya

I sugget u to close this question.

You can get answer directly from ur original question

This is just unnecessary to ask same question again for some extra ponts
Regards
Sudhakar
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial