/** * Copy the inputStream to the outputStream. Uses a buffer of the default size ({@link #DEFAULT_CHUNK_SIZE}). * * @param inputStream The input stream to read * @param outputStream The output stream to write to * * @return The number of bytes read * * @throws IOException If a problem occurred accessing either stream */ public static long copy(InputStream inputStream, OutputStream outputStream) throws IOException { return copy( inputStream, outputStream, DEFAULT_CHUNK_SIZE ); }
/** * Copy the reader to the writer. Uses a buffer of the default size ({@link #DEFAULT_CHUNK_SIZE}). * * @param reader The reader to read from * @param writer The writer to write to * * @return The number of bytes read * * @throws IOException If a problem occurred accessing reader or writer */ public static long copy(Reader reader, Writer writer) throws IOException { return copy( reader, writer, DEFAULT_CHUNK_SIZE ); }
/** * Copy the inputStream to the outputStream. Uses a buffer of the default size ({@link #DEFAULT_CHUNK_SIZE}). * * @param inputStream The input stream to read * @param outputStream The output stream to write to * * @return The number of bytes read * * @throws IOException If a problem occurred accessing either stream */ public static long copy(InputStream inputStream, OutputStream outputStream) throws IOException { return copy( inputStream, outputStream, DEFAULT_CHUNK_SIZE ); }
public static long copy(Reader reader, Writer writer) throws IOException { return copy( reader, writer, DEFAULT_CHUNK_SIZE ); }
/** * Copy the reader to the writer. Uses a buffer of the default size ({@link #DEFAULT_CHUNK_SIZE}). * * @param reader The reader to read from * @param writer The writer to write to * * @return The number of bytes read * * @throws IOException If a problem occurred accessing reader or writer */ public static long copy(Reader reader, Writer writer) throws IOException { return copy( reader, writer, DEFAULT_CHUNK_SIZE ); }
public static long copy(InputStream inputStream, OutputStream outputStream) throws IOException { return copy( inputStream, outputStream, DEFAULT_CHUNK_SIZE ); }
public static long copy(InputStream inputStream, OutputStream outputStream) throws IOException { return copy( inputStream, outputStream, DEFAULT_CHUNK_SIZE ); }
public static long copy(Reader reader, Writer writer) throws IOException { return copy( reader, writer, DEFAULT_CHUNK_SIZE ); }
public Blob createBlob(InputStream inputStream) { try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(inputStream.available()); StreamUtils.copy(inputStream, buffer); return Hibernate.getLobCreator(getSession()).createBlob(buffer.toByteArray()); } catch (Exception e) { throw new RuntimeException(e); } }
/** * {@inheritDoc} */ public Blob createBlob(InputStream inputStream, long length) { try { Blob blob = createBlob(); OutputStream byteStream = blob.setBinaryStream( 1 ); StreamUtils.copy( inputStream, byteStream ); byteStream.flush(); byteStream.close(); // todo : validate length written versus length given? return blob; } catch ( SQLException e ) { throw new JDBCException( "Unable to prepare BLOB binary stream for writing",e ); } catch ( IOException e ) { throw new HibernateException( "Unable to write stream contents to BLOB", e ); } }
/** * {@inheritDoc} */ public Clob createClob(Reader reader, long length) { try { Clob clob = createClob(); Writer writer = clob.setCharacterStream( 1 ); StreamUtils.copy( reader, writer ); writer.flush(); writer.close(); return clob; } catch ( SQLException e ) { throw new JDBCException( "Unable to prepare CLOB stream for writing", e ); } catch ( IOException e ) { throw new HibernateException( "Unable to write CLOB stream content", e ); } }
/** * {@inheritDoc} */ public Clob createClob(Reader reader, long length) { try { Clob clob = createClob(); Writer writer = clob.setCharacterStream( 1 ); StreamUtils.copy( reader, writer ); writer.flush(); writer.close(); return clob; } catch ( SQLException e ) { throw new JDBCException( "Unable to prepare CLOB stream for writing", e ); } catch ( IOException e ) { throw new HibernateException( "Unable to write CLOB stream content", e ); } }
/** * {@inheritDoc} */ public NClob createNClob(Reader reader, long length) { try { NClob nclob = createNClob(); Writer writer = nclob.setCharacterStream( 1 ); StreamUtils.copy( reader, writer ); writer.flush(); writer.close(); return nclob; } catch ( SQLException e ) { throw new JDBCException( "Unable to prepare NCLOB stream for writing", e ); } catch ( IOException e ) { throw new HibernateException( "Unable to write NCLOB stream content", e ); } }
/** * {@inheritDoc} */ public NClob createNClob(Reader reader, long length) { try { NClob nclob = createNClob(); Writer writer = nclob.setCharacterStream( 1 ); StreamUtils.copy( reader, writer ); writer.flush(); writer.close(); return nclob; } catch ( SQLException e ) { throw new JDBCException( "Unable to prepare NCLOB stream for writing", e ); } catch ( IOException e ) { throw new HibernateException( "Unable to write NCLOB stream content", e ); } }
/** * {@inheritDoc} */ public Blob createBlob(InputStream inputStream, long length) { try { Blob blob = createBlob(); OutputStream byteStream = blob.setBinaryStream( 1 ); StreamUtils.copy( inputStream, byteStream ); byteStream.flush(); byteStream.close(); // todo : validate length written versus length given? return blob; } catch ( SQLException e ) { throw new JDBCException( "Unable to prepare BLOB binary stream for writing",e ); } catch ( IOException e ) { throw new HibernateException( "Unable to write stream contents to BLOB", e ); } }