Blob 쓰기 파일

1961 단어
1. 출력 스트림을 정의하여 파일에 쓸 수 있는 Spring 자체 접근 방식
                final OutputStream os;
                os = new FileOutputStream(new File("300.zip"));
                FileCopyUtils.copy(blob.getBinaryStream(), os);

2. byte[]로 전환하여 쓰기
                Blob blob = rs.getBlob("FSTREAM");
                ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
                InputStream inputStream = blob.getBinaryStream();
                byte[] buff = new byte[100]; //buff             
                int rc = 0;
                while ((rc = inputStream.read(buff, 0, 100)) > 0) {
                    swapStream.write(buff, 0, rc);
                }
                byte[] fStreamByte = swapStream.toByteArray(); //in_b        
                final OutputStream os;
                os = new FileOutputStream(new File("300.zip"));
                os.write(fStreamByte);
                os.close();

좋은 웹페이지 즐겨찾기