问题
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