I am reading the file system for media files.
Now i want to read a particular media file(audio/video or pic) and store it in byte array(B64 converted) .
When i try doing it using inputStream, i always get outofMemoryException because the media file size is big.
Is there a mechanism(or code) where in i can give the inputstream on media and it can be done in chunks i.e. some B64 utility which can take inputstream and populate byte out of it ..and also take care of big size.
Since your media size is too big to be entirely handled in Java memory, you must find some alternative solutions:
* if you access network media, you could use RTSP streaming (where supported)
* otherwise, you could split your media in smaller pieces and playback one after the other (for audio/video media).. not optimal, but often used where RTSP is not supported
* for pics, if they're too big for Java heap memory, the only thing you can do is to resize them
If your task is only to locally save media, you could instead use a progressive download & save approach, saving chunks of bytes one after the other (so, without the need to handle the whole media all at once).
zappit, i dont need to play ..or download..
i need to upload .and i have to upload in a defined xml format ..so i need the whole mediaContent in byte.
I need a mechanism wherein i can convert a media on device(local file system) into a B64 byte.
So i need a reading mechanism and converting to B64 mechanism both of which should handle large size( doing magic internally of breaking it and converting ..but interface should be able to take big) .
If someone has already done it(it is quite common i think) ..so thought of posting it here ..!