Memory Mapped Files in Java is rather new java concept for many programmers and developers, though it’s been there from JDK 1.4 along with java.nio package. Java IO has been considerably fast after introduction of NIO and memory mapped file offers fastest IO operation possible in Java and quite useful in high frequency trading space, where electronic trading system needs to be super fast and one way latency to exchange has to be on sub-micro second level. IO has always been concern for performance sensitive applications and memory mapped file allows you to directly read from memory and write into memory. There are some other advantage also which we will see in next section.
key advantage of Memory Mapped File is that operating system takes care of reading and writing and even if your program crashed just after writing into memory. OS will take care of writing content to File.
Another key advantage is shared memory, memory mapped files can be accessed by more than one process and can be act as shared memory with extremely low latency. See Peter's comment also on comment section.
Earlier we have seen how to read xml file in Java and how to read text file in java and in this Java IO tutorial we gonna look on what is memory mapped file, how to read and write from memory mapped file and important points related to Memory Mapped Files.
key advantage of Memory Mapped File is that operating system takes care of reading and writing and even if your program crashed just after writing into memory. OS will take care of writing content to File.
Another key advantage is shared memory, memory mapped files can be accessed by more than one process and can be act as shared memory with extremely low latency. See Peter's comment also on comment section.
Earlier we have seen how to read xml file in Java and how to read text file in java and in this Java IO tutorial we gonna look on what is memory mapped file, how to read and write from memory mapped file and important points related to Memory Mapped Files.