⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blobimp.java

📁 OA典型例子
💻 JAVA
字号:
package com.sure.util;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
import java.sql.Blob;
import java.sql.*;

public class BlobImp implements java.sql.Blob{

  private byte[] content = new byte[1024];

  public BlobImp(){}

  public InputStream getBinaryStream(){
    return new ByteArrayInputStream(content);
  }

  public byte[] getBytes(long pos, int length){
    byte[] buf = new byte[length];
    System.arraycopy(content, (int)pos, buf, 0, length);
    return buf;
  }

  public long length(){
    return content.length;
  }

  public long position(Blob pattern, long start){
    return 0;
  }

  public long position(byte[] pattern, long start){
    return 0;
  }

  public int getBufferSize(){
    return 1024;
  }

  public void setContent(byte[] content){
    //this.content = Base64.decode(content);
    this.content = content;
  }

  public void setContent(InputStream in){
    byte[] buf = new byte[1024];
    int length;
    try{
      while((length = in.read(buf)) != -1){
        if(content != null && content.length > 0){
          byte[] newbuf = new byte[content.length + length];
          System.arraycopy(content, 0, newbuf, 0, content.length);
          System.arraycopy(buf, 0, newbuf, content.length, length);
          content = newbuf;
        }
        else
          System.arraycopy(buf, 0, content, 0, length);
      }
    }
    catch(IOException ioe){
    }
  }

  public byte[] getContent(){
    return content;
  }
  public void truncate(long len) throws SQLException{
  }
  public java.io.OutputStream  setBinaryStream(long pos) throws SQLException{
    return new  ByteArrayOutputStream(1024) ;
  }
  public int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException{
    return 0;
  }
  public int setBytes(long pos, byte[] bytes) throws SQLException{
    return 0;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -