[jcifs] memory-mapped files

Michael B Allen ioplex at gmail.com
Wed Jul 22 10:47:21 MDT 2009

On Mon, Jul 20, 2009 at 10:25 PM, whee<whee at tut.by> wrote:
> Is it possible using jcifs package to map files on server side into memory of
> the client side?
> In core java to map part of file into memory on single computer code would
> be:
>        ByteBuffer buf = ByteBuffer.allocate(length);
>        try {
>                File f = new File(path);
>                RandomAccessFile raf = new RandomAccessFile(f, "r");
>                FileChannel rCh = raf.getChannel();
>                buf = rCh.map(FileChannel.MapMode.READ_ONLY, offset, length);
>                rCh.close();
>                raf.close();
>        } catch (Exception e) {
>                System.err.println(e);
>        }
> the realization of map method(mmap function on unix-based os and
> CreateFileMapping+MapViewOfFile on windows os) of FileChannel Class decrease
> the time of access to large blocks of file and so is very usefull.

You might be able to extend SmbRandomAccessFile to return a
FileChannel that implements the mapping behavior required by
ByteBuffer. But it would not improve access time since it would of
course not be doing real memory mapping.


Michael B Allen
Java Active Directory Integration

More information about the jcifs mailing list