1 首先bean里面先定义byte[] ,提供getter和setter
private byte[] sphoto;
2 使用stream流
@Test
public void image(){
List<Student> stu=dao.getStudentById(167);
for (Student student : stu) {
int len=(int) student.getSphoto().length;
byte[] pic=student.getSphoto();
System.out.println(pic.length);
String dir="C:/Users/qhtf/Desktop/"+student.getSname()+".jpg";
FileOutputStream fos;
try {
fos = new FileOutputStream(dir);
fos.write(pic);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}