Source Code : Map FileChannel to MappedByteBuffer
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Map FileChannel to MappedByteBuffer
import java.io.FileInputStream;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
public class Main {
public static void main(String args[]) throws Exception {
String filename = args[0];
int start = 10;
int length = 20;
FileInputStream fin = new FileInputStream(filename);
FileChannel finc = fin.getChannel();
MappedByteBuffer mbb = finc.map(FileChannel.MapMode.READ_ONLY, start, length);
for (int i = 0; i < length; ++i) {
System.out.println(mbb.get(i);
}
fin.close();
}
}
Thank with us