Posted By:
Kurinchikumaran_Thavarajah
Posted On:
Wednesday, August 16, 2006 06:57 AM
hi all, I am developing a J2ME application which stores video clips(mpeg) of 5 second in a recordstore and play it later. the code is like this; InputStream is = Connector.openInputStream(url); byte[] buffer = new byte[4*1024]; ByteArrayOutputStream baos = new ByteArrayOutputStream(); while (true) { int read = is.read(buffer, 0, buffer.length); if (read < 0) { break; } baos.write(buffer, 0, read); } buffer = baos.toByteArray(); int id = fileRecordstore.addRecord(buffer, 0 , buffer.length); but when I read
More>>
hi all,
I am developing a J2ME application which stores video clips(mpeg) of 5 second in a recordstore and play it later. the code is like this;
InputStream is = Connector.openInputStream(url);
byte[] buffer = new byte[4*1024];
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while (true) {
int read = is.read(buffer, 0, buffer.length);
if (read
< 0) {
break;
}
baos.write(buffer, 0, read);
}
buffer = baos.toByteArray();
int id = fileRecordstore.addRecord(buffer, 0 ,
buffer.length);
but when I read (in the while loop) after reading some time it throws Uncaught exception java/lang/OutOfMemoryError. I changed the byte array size also, but no use. the size of the mpeg file is 406 kB. but the application work when I run it without storing.
can anyone let me know how can I change the code to eliminate this problem
Kumaran
<<Less