简体   繁体   中英

Fastest way to read/write to Random Access Files?

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.

If you want correctness across multiple read/write processes, you are going to sacrifice performance either to non-buffered APIs like RandomAccessFile, or else to inter-process locking.

You can't validly compare to what you could achieve within a single process without contention.

You could investigate MappedByteBuffer, but be aware it brings its own problems in its wake.

I personally would look into using a database. That's what they're for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM