Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 27
Registered: ‎02-12-2010
My Device: Torch 9800
My Carrier: Globe/Unlocked AT&T

How To Optimize InputStream Skip?

Any suggestions on how to optimize the skip() method in InputStream?


I'm thinking of something like this below. Are there other better implementations for the skip() method? or is this better to the default implementation, in the first place?


public long skip(final long n) throws IOException {
	byte[] b = new byte[SIZE];
	int skipped = 0;
	int read = 0;
	while ((skipped < n) || (read != -1)) {
		read = read(b);
		skipped += read;
	return skipped;