import java.io.RandomAccessFile; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; public class CreateFile{ public static void main(String[] args) throws Exception { RandomAccessFile out = new RandomAccessFile("test.txt", "rw"); FileChannel fc = out.getChannel(); int length = 0x8FFFFFF; MappedByteBuffer MappByteBuff = fc.map(FileChannel.MapMode.READ_WRITE, 0, length); for (int i = 0; i < length; i++) { MappByteBuff.put((byte) 'B'); } System.out.println("File successFully written"); } }