Hello JGO,
I would like some suggestions for a fast and reliable way of getting the available bytes in an inputstream.
InputStream.available()
doesn’t return the correct value.
I have found a way, but for me it looks really inefficient:
//"is" is the InputStream
is.mark(Integer.MAX_VALUE);
long filesize = 0;
int len;
byte[] buffer = new byte[1024];
while((len = is.read(buffer)) != -1) {
filesize+= len;
}
is.reset();
Any suggestions/improvements are welcome