View Single Post
Old 02-12-2010, 03:49 PM   #1 (permalink)
kmikedo
New Member
 
Join Date: Feb 2010
Model: 8300
PIN: N/A
Carrier: Telus
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Smile FileConnection fails after several iterations.

Please Login to Remove!

I wrote a program that periodically(every minute) receives updated data from server. Once the data is received it overwrites to the corresponding line of the file. ( code below )
Code below runs fine for first few iterations but throws IOException after.

Thanks.

try{
byte[] contents = bout.toByteArray(); // it always has fresh data.
conn = (FileConnection)Connector.open("file:///SDCard/update.txt");
if(!conn.exists())
conn.create();
out = conn.openOutputStream(index*rowSize);
out.write(contents);
}
finally{
if(conn!=null)
conn.close();
if(out!=null)
out.close();
}
Offline   Reply With Quote