JAVA/JAVA IO
ByteArrayOutputStream 사용 예제
nineDeveloper
2016. 3. 9. 19:56
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
반응형