Sending image as text in java

◇◆丶佛笑我妖孽 提交于 2019-12-23 18:40:10

问题


Is it possible to read image as text and send it over network? Is yes, then how can we do this?


回答1:


You could base64 encode the image to produce a (text) string.

Apache Commons Codec has a Base64 implementation that you can easily use:

import org.apache.commons.codec.binary.Base64;

// Read the byte array from file, DB, etc
byte[] imageByteArray = getImageByteArray();

String base64Image = Base64.encodeBase64String(imageByteArray);


来源:https://stackoverflow.com/questions/6484002/sending-image-as-text-in-java

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