Package java.nio

Examples of java.nio.MappedByteBuffer.load()


        FileInputStream fileInputStream = new FileInputStream(tmpFile);
        FileChannel fileChannelRead = fileInputStream.getChannel();
        MappedByteBuffer mmbRead = fileChannelRead.map(MapMode.READ_ONLY, 0,
                fileChannelRead.size());
       
        assertEquals(mmbRead, mmbRead.load());

        RandomAccessFile randomFile = new RandomAccessFile(tmpFile, "rw");
        FileChannel fileChannelReadWrite = randomFile.getChannel();
        MappedByteBuffer mmbReadWrite = fileChannelReadWrite.map(
                FileChannel.MapMode.READ_WRITE, 0, fileChannelReadWrite.size());
View Full Code Here


        RandomAccessFile randomFile = new RandomAccessFile(tmpFile, "rw");
        FileChannel fileChannelReadWrite = randomFile.getChannel();
        MappedByteBuffer mmbReadWrite = fileChannelReadWrite.map(
                FileChannel.MapMode.READ_WRITE, 0, fileChannelReadWrite.size());

        assertEquals(mmbReadWrite, mmbReadWrite.load());
       
        fileChannelRead.close();
        fileChannelReadWrite.close();
    }
View Full Code Here

        t = System.currentTimeMillis();
        FileChannel channel = raf.getChannel();
        r = new Random(0);
        MappedByteBuffer byteBuf3 = channel.map(FileChannel.MapMode.READ_ONLY, 0, raf.length());

        byteBuf3.load();


        for (int i = 0; i < NUNBER_OF_READS; i++) {
            int pos = r.nextInt(FILE_SIZE - BUFFER_SIZE);
View Full Code Here

                            synchronized (lock) {
                                bb = fc.map(FileChannel.MapMode.READ_WRITE, pos, BLOCK_SIZE);
                                System.out.println(ti + ": mapped");
                            }
                            synchronized (lock) {
                                bb.load();
                                System.out.println(msg + " loaded");
                            }
                            for (int k = 0, n = bb.limit(); k < n; k++) {
                                bb.put(k, (byte)(bb.get(k) + 65));
                            }
View Full Code Here

        FileInputStream fileInputStream = new FileInputStream(tmpFile);
        FileChannel fileChannelRead = fileInputStream.getChannel();
        MappedByteBuffer mmbRead = fileChannelRead.map(MapMode.READ_ONLY, 0,
                fileChannelRead.size());
       
        assertEquals(mmbRead, mmbRead.load());

        RandomAccessFile randomFile = new RandomAccessFile(tmpFile, "rw");
        FileChannel fileChannelReadWrite = randomFile.getChannel();
        MappedByteBuffer mmbReadWrite = fileChannelReadWrite.map(
                FileChannel.MapMode.READ_WRITE, 0, fileChannelReadWrite.size());
View Full Code Here

        RandomAccessFile randomFile = new RandomAccessFile(tmpFile, "rw");
        FileChannel fileChannelReadWrite = randomFile.getChannel();
        MappedByteBuffer mmbReadWrite = fileChannelReadWrite.map(
                FileChannel.MapMode.READ_WRITE, 0, fileChannelReadWrite.size());

        assertEquals(mmbReadWrite, mmbReadWrite.load());
       
        fileChannelRead.close();
        fileChannelReadWrite.close();
    }
View Full Code Here

                        final MappedByteBuffer compressedBb = cFileChannel.map(
                                FileChannel.MapMode.READ_ONLY, 0, size);

                        if (entry.type == CacheType.HEAP) {
                            compressedBb.load();
                        }
                       
                        entry.compressedBb = compressedBb;
                    } finally {
                        cFis.close();
View Full Code Here

                        final MappedByteBuffer compressedBb = cFileChannel.map(
                                FileChannel.MapMode.READ_ONLY, 0, size);

                        if (entry.type == CacheType.HEAP) {
                            compressedBb.load();
                        }
                       
                        entry.compressedBb = compressedBb;
                    } finally {
                        cFis.close();
View Full Code Here

      size = fileChannel.size();

      // get byte[] lineBytes from features file
      MappedByteBuffer mappedByteBuffer;
      mappedByteBuffer = fileChannel.map(MapMode.READ_ONLY, startByte, numBytes);
      mappedByteBuffer.load();
      mappedByteBuffer.get(lineBytes, 0, numBytes);
      fileChannel.close()// JVM garbage collector does not close these, so force closure
      fileInputStream.close()// JVM garbage collector does not close these, so force closure

      isFailedInitialization = false;
View Full Code Here

      // read portion of file into bytes[]
      try {
        MappedByteBuffer mappedByteBuffer = fileChannel.map(
                         MapMode.READ_ONLY, runningNumBytesRead, thisNumBytesRead);
        mappedByteBuffer.load();
        mappedByteBuffer.get(bytes, 0, thisNumBytesRead);
      } catch (Exception e) {
        // warn and abort
        WError.showError( "Unable to read file " + featuresFile + ".",
                          "BEViewer file read error", e);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.