Source Code : FileChannel: map(FileChannel.MapMode mode,long position,long size)
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
FileChannel: map(FileChannel.MapMode mode,long position,long size)
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
public class MainClass {
public static void main(String args[]) {
FileInputStream fileInputStream;
FileChannel fileChannel;
long fileSize;
MappedByteBuffer mBuf;
try {
fileInputStream = new FileInputStream("test.txt");
fileChannel = fileInputStream.getChannel();
fileSize = fileChannel.size();
mBuf = fileChannel.map(FileChannel.MapMode.READ_ONLY, 0, fileSize);
for (int i = 0; i < fileSize; i++)
System.out.print((char) mBuf.get());
fileChannel.close();
fileInputStream.close();
} catch (IOException exc) {
System.out.println(exc);
System.exit(1);
}
}
}
Thank with us