In the case of a file, there is a solution, because the file has a known size. (unless possibly you want to deal with certain special files, and I don't want to think about that right now). In this case, use java.io.File to get the file size. There's no general solution for all InputStream objects, because not all InputStream objects will ...