writing stream to CLOB

I have used the following code in java service to write input stream to CLOB. (Later a stored procedure is to be used for inserting this CLOB into DB)

CLOB clob = null;
clob.open(CLOB.MODE_READWRITE);
Writer out = clob.getCharacterOutputStream();
out.write(java.io.InputStream stream);
out.flush();
out.close();

As the above code was not compiled ,I tried with Writer out = clob.getAsciiOutputStream(); and got the same result.

Anyone has suggestion to write stream to CLOB?