Java:mysql取图片
/*取图片*/
Statement st=(Statement) connection.createStatement();
ResultSet rs=st.executeQuery("select im from imag");
rs.next(); //将光标指向第一行
//从rs中读取stupic放进InputStream对象中
InputStream in=rs.getBinaryStream("im");
//申明byte数组,用来存放图片流
byte[] b=new byte[60000];
in.read(b); //从InputStream对象中读取数据放进byte数组中
//实例化OutputStream对象,在D盘创建一个图片文件
FileOutputStream out=new FileOutputStream("E:/222.jpg");
//将文件输出,内容则为byte数组里面的数据
out.write(b);
out.flush();