图片,文件流的简单使用
public void getBlob() throws Exception {
OutputStream os = null;
InputStream is = null;
ResultSet rs = null;
try {
// rs = this.query("select FACEFILE from t_wepec_user where sysid='4784' ");
is = new FileInputStream("D:\\img\\yy.jpg");
// while (rs.next()){
// is = rs.getBinaryStream(1);
// Blob blob = rs.getBlob(1);
// is = blob.getBinaryStream();
OutputStream out = new FileOutputStream("D:\\img\\narcissus1.jpg");
byte[] buffer = new byte[1024];
int i = 0;
while((i = is.read(buffer)) != -1){
out.write(buffer, 0, i);
}
// }
// List<Map> list = this.queryBySql("select FACEFILE from t_wepec_user where sysid='881108302' ", 0, 1).getList();
// list.get(0).get("facefile");
// logger.info("sysid ==============="+sf);
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
is.close();
os.close();
rs.close();
} catch (IOException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
// ps.close();
}
}