Package java.nio

Examples of java.nio.MappedByteBuffer.force()


        FileChannel fileChannelReadWrite = randomFile.getChannel();
        MappedByteBuffer mmbReadWrite = fileChannelReadWrite.map(
                FileChannel.MapMode.READ_WRITE, 0, fileChannelReadWrite.size());

        mmbReadWrite.put((byte) 'o');
        mmbReadWrite.force();

        RandomAccessFile random = new RandomAccessFile(tmpFile, "rw");
        FileChannel fileChannelRW = random.getChannel();
        MappedByteBuffer resultReadWrite = fileChannelRW.map(
                FileChannel.MapMode.READ_WRITE, 0, fileChannelRW.size());
View Full Code Here


      ReadableByteChannel ch = Channels.newChannel(stream);
      ch.read(bb);
      ch.close();

      bb.force();
   }

   /**
    * Set length of the Value in bytes to the specified <code>size</code>.
    *
 
View Full Code Here

      if (channel.size() < size)
      {
         // extend file
         MappedByteBuffer bb = channel.map(FileChannel.MapMode.READ_WRITE, size, 0);
         bb.force();
      }
      else
      {
         // truncate file
         channel.truncate(size);
View Full Code Here

    MappedByteBuffer buffer = null;
    buffer = channel.map(MapMode.READ_WRITE, 0, WRITE_BATCH * WRITE_ONE);
    for (int i = 0; i < data.length; i++) {
        buffer.put(data[i]);
    }
    buffer.force();
    channel.close();
    file.close();
  }

  public void clean() throws IOException {
View Full Code Here

                  chf = SpoolFile.createTempFile("jcrvdedit", null, tempDirectory);
                  chch = new RandomAccessFile(chf, "rw").getChannel();

                  // allocate the space for whole file
                  MappedByteBuffer bb = chch.map(FileChannel.MapMode.READ_WRITE, position + length, 0);
                  bb.force();
                  bb = null;

                  ReadableByteChannel bch = Channels.newChannel(new ByteArrayInputStream(this.data));

                  if ((newIndex = (int)position) > 0)
View Full Code Here

            ReadableByteChannel ch = Channels.newChannel(stream);
            ch.read(bb);
            ch.close();

            bb.force();
         }
      }

      /**
       * Set length of the Value in bytes to the specified <code>size</code>.
View Full Code Here

                  if (chch.size() < size)
                  {
                     // extend length
                     MappedByteBuffer bb = chch.map(FileChannel.MapMode.READ_WRITE, size, 0);
                     bb.force();
                  }
               }
               catch (final IOException e)
               {
                  try
View Full Code Here

         {
            if (spoolChannel.size() < size)
            {
               // extend file
               MappedByteBuffer bb = spoolChannel.map(FileChannel.MapMode.READ_WRITE, size, 0);
               bb.force();
            }
            else
            {
               // truncate file
               spoolChannel.truncate(size);
View Full Code Here

                }
            }
            while (last.remaining() > 0) {
                last.put(PADDING_BYTES);
            }
            last.force();
        }

        // Need to start a new file
        try {
            String name = String.format(FILE_NAME_FORMAT, files.size());
View Full Code Here

  public void flush() {
    synchronized(this) {
      if (closed) return;
      if (dirty) {
        MappedByteBuffer srcBuf = (MappedByteBuffer)threadLocalBuffer.getSourceBuffer();
        srcBuf.force(); // flush the changes
        dirty = false;
        if (logger.isDebugEnabled()) {
          logger.debug("Mapped page for " + this.pageFile + " was just flushed.");
        }
      }
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.