The reason for the big difference is the overhead associated with I / O, which occurs regardless of how much data is transferred - this is like a drop in the fall of a taxi. Overhead, which is not limited to java and includes many O / S operations, include:
- Search for a file on disk
- Check O / S permissions on a file
- Opening a file for input / output
- File closing
- Updating file information in the file system
- Many other tasks
In addition, disk I / O is performed on pages (the size depends on O / S, but usually 2K), so I / O of 1 byte probably costs the same as I / O on 2048 bytes: a slightly more fair comparison be a 2048 byte array with a 1 MB array.
If you use buffered I / O, this can speed up the execution of large I / O tasks.
Finally, what you are reporting as β10Kbβ is actually only 10 bytes, so your calculation may be incorrect.
source share