J2ME Writing PNG images to mobile phone file system usingFileConnection API JSR75

J

Juls

Hi,
is there an easy way how one can write an image file from a J2ME
Midlet to the mobile phone's file system?

My attempts so far are not very promissing:

try {
byte[] imageByte = myVideoControler.getSnapshot(null);

FileConnection connection = (FileConnection) Connector
.open("file:///C:/cameraTest.png");
if (!connection.exists()) {
connection.create();
}

OutputStream os = connection.openOutputStream();
PrintStream ps = new PrintStream(os);

for (int i = 0; i<imageByte.length; i++){
ps.print(imageByte);
}

os.close();
connection.close();
ps.close();

} catch (MediaException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

I really hope you can give me a hint how solve this problem how I can
write an image file to the file system.

Cheers
Juls
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top