byte数组转换为图形,有没有这方面的smpale?

sandsworlf 2004-06-09 03:23:16
我把图形作为byte数组存入数据库了,然后想读出来再转换为原来地图形,期待高手指点。

byte[] image = rs.getBytes("image");

数组取出来了,该怎么转换,没做过这方面地说。
...全文
84 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zuopeng 2004-06-09
  • 打赏
  • 举报
回复
Connection conn = null;
Statement stmt=null;
ResultSet set=null;
try{
String cust_id=request.getParameter("CUST_ID2");
String med_num=request.getParameter("MED_NUM2");
String sql="SELECT MED FROM CUST_MED WHERE CUST_ID ='"+cust_id+"';
conn = OurConn.getConnection();
stmt = conn.createStatement();
set = stmt.executeQuery(sql);
if(set.next()){
InputStream in = set.getBinaryStream("MED");
response.reset();
response.setContentType("image/jpeg");
byte[] b = new byte[1024];
int a=0;
int len;
while((len=in.read(b))!=-1){
response.getOutputStream().write(b);
a=1;
}
in.close();
if(a==0)
{ }
}
}catch(Exception e){

}finally{
try{
if(set!=null)
set.close();
}catch(java.sql.SQLException se){
}
try{
if(stmt!=null)
stmt.close();
}catch(java.sql.SQLException se){
}
try{
if(conn != null )
conn.close();
}catch(java.sql.SQLException se){
}
}
survive 2004-06-09
  • 打赏
  • 举报
回复
查查jdk,

应该有createImage(byte[])

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧