1

Note: I have seen similar questions but all referring to large files. This is for small amounts reading and writing constantly, and many files will be written to and read from at once, so performance will be a issue.

Currently, I'm using a Random Access File for an "account" it's fast with basic I/O:

raf.write();

I have seen random access files with file channels and buffered I/O what is the fastest(again for small data.), and could you please supply a example of your proof.

4

1 回答 1

1

如果您想要跨多个读/写进程的正确性,您将牺牲性能,或者牺牲非缓冲 API(如 RandomAccessFile),或者牺牲进程间锁定。

您无法有效地比较您可以在没有争用的情况下在单个流程中实现的目标。

您可以调查 MappedByteBuffer,但要注意它会带来自己的问题。

我个人会考虑使用数据库。这就是他们的目的。

于 2013-02-11T09:12:50.270 回答