当前位置: 技术问答>java相关
怎样保存image?着急,再线等待
来源: 互联网 发布时间:2015-10-16
本文导语: 怎样保存image?着急,再线等待 | Iterator writers = ImageIO.getImageWritersByFormatName("jpeg"); ImageWriter writer = (ImageWriter)writers.next(); ImageOutputStream ios = null; try{ ios = ImageIO.createImageOutputStream(new Fi...
怎样保存image?着急,再线等待
|
Iterator writers = ImageIO.getImageWritersByFormatName("jpeg");
ImageWriter writer = (ImageWriter)writers.next();
ImageOutputStream ios = null;
try{ ios = ImageIO.createImageOutputStream(new FileOutputStream("myPicture.jpg"));}
catch(IOException ioe){}writer.setOutput(ios);
try{ writer.write(bufferedImage);}
catch(IOException ioe){}
package javax.imageio available since JDK 1.4
ImageWriter writer = (ImageWriter)writers.next();
ImageOutputStream ios = null;
try{ ios = ImageIO.createImageOutputStream(new FileOutputStream("myPicture.jpg"));}
catch(IOException ioe){}writer.setOutput(ios);
try{ writer.write(bufferedImage);}
catch(IOException ioe){}
package javax.imageio available since JDK 1.4
|
strSql=" update REPORT set REPORT_CONTENT = ? where REPORT_ID=22" PreparedStatement preStmt = dbconn.prepareStatement ( strSql ) ;
byte[] contentBook = jBreport.writeToBlob () ;
ByteArrayInputStream inStream = new ByteArrayInputStream( contentBook ) ;
preStmt.setBinaryStream( 1 , inStream , inStream.available () ) ;
preStmt.executeUpdate () ;
其中REPORT_CONTENT就是image型。
byte[] contentBook = jBreport.writeToBlob () ;
ByteArrayInputStream inStream = new ByteArrayInputStream( contentBook ) ;
preStmt.setBinaryStream( 1 , inStream , inStream.available () ) ;
preStmt.executeUpdate () ;
其中REPORT_CONTENT就是image型。