Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reader Object  RSS feed

 
Lim Youjie
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i am using a reader object to read input.

int next = reader.read();
if (next != -1) //if not end of input
{
char c = (char) next; //cast "next" into character and store in "c"
System.out.println(c);
}

may i know what reader.read() will return when it is end of input and space?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you read a space, read() will return... a space.

When you get to the end of the input, read() will return -1 -- but given the code you've shown, it's not clear that you don't already know that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!