7

如何测试EOFR 中的标志?

例如:

f <- file(fname, "rb")
while (???) {
    a <- readBin(f, "int", n=1)
}
4

2 回答 2

7

The readLines function will return a zero-length value when it reaches the EOF.

于 2008-09-19T16:20:30.987 回答
5

尝试检查 readBin 返回的数据长度:

while (length(a <- readBin(f, 'int', n=1)) > 0) {
    # do something
}
于 2009-07-30T07:09:28.827 回答