JAVA读取BLOB

2014-10-30 16:15:07 · 作者: · 浏览: 90

  Java代码


  Blob blob = rs.getBlob("article_content");


  InputStream instream = blob.getBinaryStream();


  int flength=(int)blob.length();


  byte[] b = new byte[flength];


  byte[] nb=new byte[1024];


  int len=0;


  int tlen=0;


  while(flength>0){


  len=instream.read(nb);


  System.arraycopy(nb, 0, b, tlen, len);


  tlen+=len;


  flength-=len;


  }


  instream.close();


  a.setArticleContent(new String(b,"GBK"));


  编辑特别推荐: