DataOutputStream.size()

The method size() in DataOutputStream returns int.

This should be long IMO.

I am using DataOutputStream to generate huge files, and for a while, I nahively used the size() method to track my progress (and to generate an index into parts of the generated file).

Needless to say my program did not work for offsets over Integer.MAX_VALUE. (My fault of course, for not reading the Javadoc to detail.)

But the question is, shouldn't size() return long?

Reuben

[494 byte] By [reuben-sa] at [2007-10-2 20:36:41]
# 1

please be aware, i am know not much about java.

but take a look at:

DataOutputStream.flush();

a wild guess might be that "size()" returns the position in the

output buffer.

and you might be able to clear that buffer, and reset "size()" to

zero if you periodically call "flush()".

it should be easy to test.

please don't deride me if that is laughably wrong.

-d

dew2hirooa at 2007-7-13 23:19:55 > top of Java-index,Core,Core APIs...
# 2
Err, no, enough guessing. DataOutputStream.size() returns what the Javadoc says it returns.
ejpa at 2007-7-13 23:19:55 > top of Java-index,Core,Core APIs...