现在的位置: 首页 > 综合 > 正文

java 中File.length() 和InputStream.avalible()

2017年09月30日 ⁄ 综合 ⁄ 共 537字 ⁄ 字号 评论关闭

1. File.length()

Returns the length of this file in bytes. Returns 0 if the file does not exist. The result for a directory is not defined.

2. InputStream.avalible()

Returns an estimated number of bytes that can be read or skipped without blocking for more input.

..It
is particularly important to realize that you 
must not use
this method to size a container and assume that you can read the entirety of the stream without needing to resize the container.

..if you're reading from a file, length() returns
the current length of the file (though assuming the file's length can't change may be incorrect, reading a file is inherently racy).

【上篇】
【下篇】

抱歉!评论已关闭.