Class MemoryMappedFileUtils
- java.lang.Object
-
- net.haesleinhuepf.clij.coremem.memmap.MemoryMappedFileUtils
-
public final class MemoryMappedFileUtils extends Object
- Author:
- royer
-
-
Constructor Summary
Constructors Constructor Description MemoryMappedFileUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MemoryMappedFileAccessModebestMode(StandardOpenOption[] pStandardOpenOption)Determines best access mode gigen standard open options.static longfilesize(FileChannel pFileChannel)Returns the file size for a given file channelstatic longmap(FileChannel pFileChannel, MemoryMappedFileAccessMode pAccessMode, long pFilePosition, long pMappedRegionLength, boolean pExtendIfNeeded)Maps a region of a file.static voidtruncate(FileChannel pFileChannel, long pLength)Truncates file for given file channelstatic intunmap(FileChannel pFileChannel, long pMemoryMapAddress, long pMappedRegionLength)Unmaps memory mapped file.
-
-
-
Method Detail
-
map
public static final long map(FileChannel pFileChannel, MemoryMappedFileAccessMode pAccessMode, long pFilePosition, long pMappedRegionLength, boolean pExtendIfNeeded) throws MemoryMapFileException
Maps a region of a file.- Parameters:
pFileChannel- file channelpAccessMode- access modepFilePosition- file position in bytespMappedRegionLength- mapped region lengthpExtendIfNeeded- extend file length if needed (file not as long as request mapping length).- Returns:
- mapped address
- Throws:
MemoryMapFileException- thrown if problem occurs while mapping.
-
unmap
public static final int unmap(FileChannel pFileChannel, long pMemoryMapAddress, long pMappedRegionLength) throws MemoryMapFileException
Unmaps memory mapped file.- Parameters:
pFileChannel- file channelpMemoryMapAddress- mapped addresspMappedRegionLength- mapped region length- Returns:
- return code
- Throws:
MemoryMapFileException- thrown if problem occurs while unmapping
-
filesize
public static final long filesize(FileChannel pFileChannel) throws IOException
Returns the file size for a given file channel- Parameters:
pFileChannel- file channel- Returns:
- file size in bytes
- Throws:
IOException- exception
-
truncate
public static final void truncate(FileChannel pFileChannel, long pLength) throws IOException
Truncates file for given file channel- Parameters:
pFileChannel- file channelpLength- truncation length- Throws:
IOException- thrown if problem while truncating file
-
bestMode
public static MemoryMappedFileAccessMode bestMode(StandardOpenOption[] pStandardOpenOption)
Determines best access mode gigen standard open options.- Parameters:
pStandardOpenOption- standard open options- Returns:
- best access mode
-
-