Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Store huge file to RMS (More than 100kb)

 
kenny wen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application will connect to internet and get a huge image file, my problem is i was unable to save the image file to the RMS. My application will throw out of memory exception. Is't the byte[] byteArray; cannot store more than 64kb data? If that is the case how can i display images or video more than 64kb?

this is my sample code (http connection):
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream strmDataType = new DataOutputStream(baos);
for(int i =0 ; i < length ; i++ )
{
c = in.read();
strmDataType.writeByte(c);
}

strmDataType.flush();
byteArray = baos.toByteArray();
strmDataType.close();
baos.close();
strmDataType = null;
baos = null;

I will get "uncaught error: out of memory" when i try to download an image more than 80kb.

is't possible to contruct an image object more than 100kb?
myImage = Image.createImage(raw, 0, raw.length);

Thanks
 
Alfredo Estrada
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thats, ok, but I sugest that use the readFully() method, for faster
 
Eduardo Marques
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not required to store video/audio data to RMS before playing it.
Only if you want to retrieve and play it again it later from the RMS ...

MMAPI lets you play audio/video data from an URL directly ...

Most devices will probably not allow much RMS data... anyway you may try reserving as much as possible using MIDlet-Data-Size ... (check the MIDP 2.0 specs).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic