How can I send a picture in Java ME?

倾然丶 夕夏残阳落幕 提交于 2019-12-11 00:16:44

问题


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)
{


来源:https://stackoverflow.com/questions/388897/how-can-i-send-a-picture-in-java-me

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!