如何把Image对象中存放的信息存到数据库当中?

来源:百度知道 编辑:UC知道 时间:2024/09/23 05:55:28
做Swing时,通过java把Image对象中的内容存放到数据库当中 ,
请给出代码片段,谢谢
Image对象是通过JAVA画出来的,
或者通过剪切板出来的,
不是文件。

File f = new File("e:\\214.jpg");
FileInputStream stream = new FileInputStream(f);
ByteArrayOutputStream out = new ByteArrayOutputStream(1000);
byte[] b = new byte[1000];
int n;
while ((n = stream.read(b)) != -1){
out.write(b, 0, n);
}
out.toByteArray();
stream.close();
out.close();

pstmt.setBlob(4, new SerialBlob(b));