728x90
반응형
오라클에 BLOB TYPE 의 데이터를 읽어서 byte[] 로 저장하는 방법
BLOB b = (BLOB)pkgContents.get("BINARY_DATA");
[출처] ByteArrayOutputStream 사용 예제|작성자 GENERAL
InputStream is = null;
ByteArrayOutputStream os = null;
byte[] result = null;
try {
byte[] buf = new byte[1024];
is = b.getBinaryStream();
os = new ByteArrayOutputStream();
int readCnt = 0;
while((readCnt = is.read(buf)) != -1){
os.write(buf,0,readCnt);
}
os.flush();
result = os.toByteArray();
logger.info("MO 사이즈 :: " + result.length);
728x90
반응형
'JAVA > JAVA IO' 카테고리의 다른 글
파일을 로딩하여 ByteArrayOutputStream 으로 리턴하기 (0) | 2016.03.09 |
---|---|
[ java ] ByteBuffer (0) | 2016.03.09 |
[ java ] NIO 방식으로 파일에 쓰기 (0) | 2016.03.09 |
[ java ] FileDescriptor 클래스를 이용한 스트림 생성 (0) | 2016.03.09 |
[ java ] File 저장시 덮어쓰기 방지 (0) | 2016.03.09 |
[ java ] File 객체의 출력스트림 생성 (0) | 2016.03.09 |
[ java ] File 객체 (0) | 2016.03.09 |
자바에서 스트림 (stream) 이란. (0) | 2016.03.09 |