Code: Select all
/** Return a line of input from System.in,
* or null if EOF.
*/
static String ReadLn ()
{
int inbyte = -1;
StringBuffer line = new StringBuffer();
try
{
inbyte = System.in.read();
while ((inbyte >= 0) && (inbyte != '\n'))
{
line.append((char) inbyte);
inbyte = System.in.read();
}
}
catch (IOException e)
{
return (null);
}
if ((inbyte < 0) && (line.length() == 0)) return (null); // eof
return line.toString();
}