本例子的目的在于测试往oracle数据库中插入blob字段
public static string getimgstr(string imgfile){
//将图片文件转化为字节数组字符串,并对其进行base64编码处理
inputstream in = null;
byte[] data = null;
//读取图片字节数组
try
{
in = new fileinputstream(imgfile);
data = new byte[in.available()];
in.read(data);
in.close();
}
catch (ioexception e)
{
e.printstacktrace();
}
return new string(base64.encodebase64(data));
}
--
利用以上的思路写的一个测试
public class readimagetest {
public static void main(string[] args) throws ioexception {
fileinputstream fis = new fileinputstream(new file("c:\\users\\luzhifei\\pictures\\hc_logo.png"));
string picstr="";
byte[] read = null;
int len = 0;
read