Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create RandomAccessFile from InputStream?

Tags:

java

java-io

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?

like image 209
Koerr Avatar asked Jul 01 '26 00:07

Koerr


1 Answers

Yes, for random access of an InputStream you must buffer the stream (at least up to the point requested). A library like Unified I/O should work, or you can implement DataInput and DataOutput, which will have your class operating like a RandomAccessFile except for the file part if you have custom buffering needs.

like image 181
Peter DeWeese Avatar answered Jul 02 '26 13:07

Peter DeWeese



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!