首先服务器用的是openjdk7,下面是读取图片的代码
public static JSONObject getPicDetail(String picPath) {
JSONObject picObj = new JSONObject();
try {
File picFile = new File(picPath);
if (!picFile.exists()) {
return null;
}
BufferedImage bi = ImageIO.read(picFile);
picObj.put("width", bi.getWidth());
picObj.put("height", bi.getHeight());
ByteArrayOutputStream bs = new ByteArrayOutputStream();
ImageIO.write(bi, "jpg", bs);
byte[] bytes = bs.toByteArray();
picObj.put("binary", new Binary(bytes));
} catch (Exception e) {
return null;