This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

read( ) method

 
Urooj Ajmal
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i use while((inst.read() != -1) condition to read from a stream, it reads skipping alternate characters. help!
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens inside your loop, another inst.read() ?
 
Jerel Wakayama
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When i use while((inst.read() != -1) condition to read from a stream, it reads skipping alternate characters. help!
Example:
int i = 0;
while((i = inst.read()) != -1) {
//do stuff
}
Counter Example:
while(inst.read() != -1) {
//read() already called once above.
int i = inst.read();
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!