当前所在位置:珠峰网资料 >> 计算机 >> Oracle认证 >> 正文
向Oracle数据库blob图片字段写入图片流(五)
发布时间:2010/10/24 15:11:15 来源:www.xue.net 编辑:城市总裁吧

    //   Utility   function   to   put   data   in   a   Blob

    static   void   fillBlob   (Connection   conn,   BLOB   blob,   long   length)

    throws   Exception

    {

    OutputStream   outstream   =   blob.getBinaryOutputStream();

    int   i   =   0;

    int   chunk   =   10;

    byte   []   data   =   {   1,   2,   3,   4,   5,   6,   7,   8,   9,   10   };

    while   (i   <   length)

    {

    data   [0]   =   (byte)i;

    outstream.write(data,   0,   chunk);

    i   +=   chunk;

    if   (length   -   i   <   chunk)

    chunk   =   (int)   length   -   i;

    }

    outstream.close();

    }

    }

    给你这个例子看看,一看就明白了

广告合作:400-664-0084 全国热线:400-664-0084
Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号
珠峰网 版权所有 All Rights Reserved