如何测试EOF
R 中的标志?
例如:
f <- file(fname, "rb")
while (???) {
a <- readBin(f, "int", n=1)
}
The readLines function will return a zero-length value when it reaches the EOF.
尝试检查 readBin 返回的数据长度:
while (length(a <- readBin(f, 'int', n=1)) > 0) {
# do something
}