Sevlet端:
String imagePath = "E:\\MyDocument\\Pictures\\image.jpg";
FileInputStream fis = new FileInputStream(imagePath);
int size = fis.available(); // 得到文件大小
byte data[] = new byte[size];
fis.read(data); // 读数据
fis.close();
response.setContentType("image/jpeg"); // 设置返回的文件类型
OutputStream os = response.getOutputStream();
os.write(data);
os.flush();
os.close();
Android:
InputStream inputStream = new BufferedInputStream(HttpURLConnection.getInputStream());
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);