• Post Reply Bookmark Topic Watch Topic
  • New Topic

InutStream problem  RSS feed

 
Neel Chow
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am reading an inputstream .

while ((theInt = in.read()) >= 0) {
b[0] = (byte)theInt;
sRet = sRet + new String(b);
}
}
My problem is sometimes i read really big inputstream and my code reads it one character at a time which slows down the process.
How to solve it??
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at some of the other read methods in the JavaDoc. One of them will let you read a bigger chunk of bytes at a time. Make note of the return type - you'll have to keep track of how many were actually read to know when you're done and to know how many to add to your output.
[ April 21, 2005: Message edited by: Stan James ]
 
acttwoinc
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using the read(byte) parameter methods.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!