code: private static File writeToMapped(BytesMessage msg, File file) throws IOException, JMSException
  	{
  		// writeToMapped(msg, file.toPath());
  
  		ByteBuffer buf;
  		FileChannel fc=null;
  		RandomAccessFile raf=null;
  
  		try
  		{
  			raf = new RandomAccessFile(file, "rw");
  			fc = raf.getChannel();
  			buf = fc.map(FileChannel.MapMode.READ_WRITE, 0, msg.getBodyLength());
  			logger.debug("Writting message to byte buffer.");
  			writeTo(msg, buf);
  			logger.debug("Success writing message to file {} using file map. Closing", file);
  			fc.close();
  			raf.close();
  			return file;
  		}
  		finally
  		{
  			fc=Closer.close(fc);
  			raf=Closer.close(raf);
  		}
  	}
docs: /* blasted. java 7
  private static Path writeToMapped(BytesMessage msg, Path path) throws IOException, JMSException
  {
  ByteBuffer buf;
  FileChannel fc;
  
  try
  (
  FileChannel fc = FileChannel.open(path, EnumSet.of(StandardOpenOption.CREATE_NEW));
  )
  {
  logger.debug("Mapping file {}", file);
  buf = fc.map(FileChannel.MapMode.READ_WRITE, 0, msg.getBodyLength());
  logger.debug("Writting message to byte buffer.");
  writeTo(msg, buf);
  logger.debug("Success writing message to file {} using file map.", file);
  return path;
  }
  }