Skip to Content
Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition
book

Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition

by Ivor Horton
December 2004
Beginner
1512 pages
43h 39m
English
Wrox
Content preview from Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition

11.9. Memory-Mapped Files

A memory-mapped file is a file that has its contents mapped into an area of virtual memory in your computer. This enables you to reference or update the data in the file directly without performing any explicit file read or write operations on the physical file yourself. When you reference a part of the file that is not actually in real memory, it will be automatically paged in by your operating system. The memory that a file maps to may be paged in or out by the operating system, just like any other memory in your computer, so its immediate availability in real memory is not guaranteed. Because of the potentially immediate availability of the data it contains, a memory-mapped file is particularly useful when you need to access the file randomly. Your program code can reference the data in the file just as though it were all resident in memory.

Mapping a file into memory is implemented by a FileChannel object. The map() method for a FileChannel object will return a reference to a buffer of type MappedByteBuffer that will map to a specified part of the channel's file:

map(int mode,
    long position,
    long size)
Maps a region of the channel's file to a buffer of type MappedByteBuffer. The file region that is mapped starts at position in the file and is of length size bytes. The first argument, mode, specifies how the buffer's memory may be accessed and can be any of the following three constant values, which are defined in the MapMode class, which is a static ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Just Java™ 2

Just Java™ 2

Peter van der Linden
PURE Java™ 2

PURE Java™ 2

Kenneth Litwak
Professional Java® JDK®, 6th Edition

Professional Java® JDK®, 6th Edition

W. Clay Richardson, Jeff Scanlon, Donald Avondolio, Mark W. Mitchell, Scot Schrager
The Human Factor in AI-Based Decision-Making

The Human Factor in AI-Based Decision-Making

Philip Meissner, Christoph Keding

Publisher Resources

ISBN: 9780764568749Purchase book