Java ByteBuffer Write writeFileFragment(FileChannel fc, long pos, ByteBuffer fragment)

Here you can find the source of writeFileFragment(FileChannel fc, long pos, ByteBuffer fragment)

Description

write File Fragment

License

Open Source License

Declaration

public static boolean writeFileFragment(FileChannel fc, long pos, ByteBuffer fragment) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class Main {
    public static boolean writeFileFragment(FileChannel fc, long pos, ByteBuffer fragment) {
        try {//from  ww w  . j  a va2s  .com
            fc.position(pos);
            int size = fragment.remaining();
            if (fc.write(fragment) != size)
                return false;
            fc.force(false);
        } catch (IOException ex) {
            ex.printStackTrace();
            return false;
        }
        return true;
    }
}

Related

  1. writeFakeImageData(ByteBuffer out, int lzwMinCodeSize)
  2. writeFFloat(ByteBuffer buffer, float value)
  3. writeFile(ByteBuffer data, File destination)
  4. writeFile(File file, ByteBuffer bb)
  5. writeFile(File file, ByteBuffer buffer)
  6. writeFloat(ByteBuffer buffer, float f)
  7. writeFromBuffer(SocketChannel channel, ByteBuffer buf, int sleepMsecs)
  8. writeFully(@Nonnull final FileChannel dst, @Nonnull final ByteBuffer src, @Nonnegative final long position)
  9. writeFully(ByteBuffer buf, WritableByteChannel out)