10-15-2008 05:37 PM
the read() method in inputStream class is blocking. I want to use available() method to provide an unblocked condition: ie. only call read() method when available() return a number greater than 0.
However, the method available() in InputStream class is not implemented and always return 0. it is useless. How to solve this problem?
10-15-2008 08:34 PM
Generally the easiest thing to do is launch your own loader thread that can block without consequence.
You can subclass stream and implement available if you like. I haven't looked but there may be some buffered
stream classes you can use, I usually end up writing my own because I want to instrument them.
10-15-2008 09:05 PM
Well, you need something to override it with. Presumably there are some internal or native buffers and maybe you could
get hacked system dependent code to access these but more realistically in java you have to
create your own buffer and report available on that.
I can't find a good example here but see if you can,
So far on the BB apps, it has made more sense to just buffer entire files and let the buffer worry about retry or messed up
connections rather than dribble pieces of data to the consumer. Unless you are doing some kind of streaming this may make
sense for you.