Could someone tell me how to get length of inputStream?
The inputStream is generated on the fly and will be written into database.
I can use temporary FileInputStream to get the length. But it looks awful. Do we have any elegant way?
Thanks in advance.
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?