This is an example for writing an image file (provided that you have its byte array imgdata available in memory):
Code:
FileConnection w=(FileConnection) Connector.open("file:///E:/Testapp1/",Connector.READ_WRITE);
//Creates the folder
w.mkdir();
w.close();
FileConnection wf=(FileConnection) Connector.open("file:///E:/Testapp1/image1.jpg",Connector.READ_WRITE);
if(!wf.exists())
{
//Creates the file
wf.create();
System.out.println("Created!");
}
else
{
System.out.println("Already exists!");
}
OutputStream fos=wf.openOutputStream();
fos.write(imgdata);
fos.flush();
fos.close();
wf.close();