1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| private void transfererPhoto(String url)
{
HttpConnection httpConn = null;
DataOutputStream dos = null;
int rawId;
try {
httpConn = (HttpConnection) Connector.open(url, Connector.READ_WRITE);
httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.0");
dos = httpConn.openDataOutputStream();
try {
rsImage = RecordStore.openRecordStore("photoDB", true);
rawId = Integer.parseInt(vRawPhotoIDs.elementAt(buttonIdx).toString());
byte[] byteRequest = rsImage.getRecord(rawId);
for( int i = 0; i < byteRequest.length; i++ ) {
dos.writeByte(byteRequest[i]);
}
dos.flush();
rsImage.closeRecordStore();
} catch (RecordStoreException ex) {
}
}
catch (IOException ex) {
}
finally {
if ( dos != null )
{
try {
dos.close();
} catch (IOException ex) {}
}
if ( httpConn != null )
{
try {
httpConn.close();
} catch (IOException ex) {}
}
}
} |
Partager