The only way I know is to write a temp file, and read this file to create RandomAccessFile ,check it here
or use Use Unified I/O library (http://uio.imagero.com) here
Would this be the best way? Or can use temp file and the imageio library to implement it?