79531301

Date: 2025-03-24 14:19:51
Score: 1
Natty:
Report link

Uh oh!

buffer.length should be buffer.length - 1

The index of an array starts at 0 but the length starts at 1, therefore, you must use buffer.length - 1.

Your program must wait until the Buffer has data available.

URL is deprecated, BTW.

InputStream is = new BufferedInputStream(uc.getInputStream());
while(is.count < 1024) ;
//do other stuff
is.close();

Where is `buffer` declared?

Perhaps a simple LOGGER.info("InputStream Successfully initialized!") or System.out.println("InputStream Successfully initialized!"); statement will give a large enough delay to let the buffer fill up.

Sometimes, the minuscule delay caused by a `print` statement can make a surprisingly large difference.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Langdon Staab