ALL
NIO vs IO in Java
Java 1.4 provides a new API for handling IO -- NIO. This is a non-blocking and buffer oriented IO API.Below are main differences between the NIO and IO in Java.IONIOStream orientedBuffer orientedBlocking IONon-blocking ION/AUsing selectorStream oriented vs Buffer orientedThe main difference is that IO is stream oriented where the data is read byte by byte and the data will not be buffered normally.This means there is no pointer to move forward and backward in the stream. If there is a need to move forward and backward of the stream, the data needs to be explicitly copied to a buffer. While Jav...
Using MemoryMappedBuffer to handle large file in Java
When handling large files, it will largely affect the process speed while using traditional FileInputStream, FileOutputStream or RandomAccessFile since they trigger lots of read and write operations. In Java NIO, a new way of handling large file is introduced which is to use MmeoryMappedBuffer to create memory mapped file.Memory-mapped I/O uses the filesystem to establish a virtual memory mapping from user space directly to the applicable filesystem pages. With a memory-mapped file, you can pretend that the entire file is in memory and that you can access it by simply treating it as a very lar...
Java Sequential IO Performance
Many applications record a series of events to file-based storage for later use. This can be anything from logging and auditing, through to keeping a transaction redo log in an event sourced design or its close relative CQRS. Java has a number of means by which a file can be sequentially written to, or read back again. This article explores some of these mechanisms to understand their performance characteristics. For the scope of this article I will be using pre-allocated files because I want to focus on performance. Constantly extending a file imposes a significa...
3,206 0 JAVA IO SEQUENTIAL BLOCKING