Are you referring to PreparedStatement's:
void setBinaryStream(int parameterIndex, InputStream x, int length)
That length is a pain. If needed, I use ByteArrayOutput/InputStream in this case.
You can't know how many bytes you will read from an InputStream, in general, until you read them. It's possible that a particular subclass could give you this information but you can't expect all subclasses to do that.
If you're asking because you need a number to give to PreparedStatement.setBinaryStream, have you tried passing zero for that parameter? Or Integer.MAX_VALUE?