How can I send a picture in Java ME?

2019-07-21 03:24发布

问题:

How can I send a picture in Java ME ? Maybe using base64 decode and the send in post form via http request

回答1:

I think you looking for this image base64 encoding in J2me



回答2:

Yes , I'm use that to send the base64 ,putting in

// write your picture data to os

os.write (data);

where data = String with a base64 image , the problem is that i don't have a base64 library that works in java and asp in the same way.



回答3:

Have you considered using a "multipart/form-data" encoding type? If you so, then there is no need for Base64 encoding. See here and here for instructions on how to build the request.

If you still want to do the Base64 encoding, then you will be able to easily find many source implementations on the Web. If you are developing both the server and client side, you could use your own implementation on both ends.



回答4:

There are plenty of coders in Base64 for Java. Apache commons has one, here is a standalone one.



回答5:

HttpConnection connection = (HttpConnection) Connector.open("http://www.myserver.com");
connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty("Content-Type","image/png");
OutputStream os = connection.getOutputStream();
// write your picture data to os
os.flush();

if (connection.getResponseCode() == HttpConnection.HTTP_OK)
{


标签: image java-me