1 21 22 package org.continuent.sequoia.common.protocol; 23 24 import java.io.IOException ; 25 import java.io.OutputStream ; 26 import java.sql.SQLException ; 27 28 36 public class ByteArrayBlobOutputStream 37 extends OutputStream 38 { 39 40 ByteArrayBlob blob; 41 42 int currentPos; 43 44 51 public ByteArrayBlobOutputStream(ByteArrayBlob b, int startPos) 52 { 53 super(); 54 this.blob = b; 55 currentPos = startPos; 56 } 57 58 61 public void write(int b) throws IOException 62 { 63 blob.getInternalByteArray()[currentPos] = (byte) b; 64 currentPos++; 65 } 66 67 70 public void write(byte[] b, int off, int len) throws IOException 71 { 72 try 73 { 74 blob.setBytes(currentPos + 1, b, off, len); 76 currentPos += len; 77 } 78 catch (SQLException sqle) 79 { 80 throw (IOException ) new IOException (sqle.getLocalizedMessage()) 81 .initCause(sqle); 82 } 83 84 } 85 86 } 87 | Popular Tags |