jdk/src/share/classes/javax/crypto/CipherOutputStream.java
changeset 25176 3c2ba9344cbf
parent 17917 9bd1b39cdbcf
equal deleted inserted replaced
25175:a97b521192b6 25176:3c2ba9344cbf
   112     /**
   112     /**
   113      * Writes the specified byte to this output stream.
   113      * Writes the specified byte to this output stream.
   114      *
   114      *
   115      * @param      b   the <code>byte</code>.
   115      * @param      b   the <code>byte</code>.
   116      * @exception  IOException  if an I/O error occurs.
   116      * @exception  IOException  if an I/O error occurs.
   117      * @since      JCE1.2
       
   118      */
   117      */
   119     public void write(int b) throws IOException {
   118     public void write(int b) throws IOException {
   120         ibuffer[0] = (byte) b;
   119         ibuffer[0] = (byte) b;
   121         obuffer = cipher.update(ibuffer, 0, 1);
   120         obuffer = cipher.update(ibuffer, 0, 1);
   122         if (obuffer != null) {
   121         if (obuffer != null) {
   136      *
   135      *
   137      * @param      b   the data.
   136      * @param      b   the data.
   138      * @exception  NullPointerException if <code>b</code> is null.
   137      * @exception  NullPointerException if <code>b</code> is null.
   139      * @exception  IOException  if an I/O error occurs.
   138      * @exception  IOException  if an I/O error occurs.
   140      * @see        javax.crypto.CipherOutputStream#write(byte[], int, int)
   139      * @see        javax.crypto.CipherOutputStream#write(byte[], int, int)
   141      * @since JCE1.2
       
   142      */
   140      */
   143     public void write(byte b[]) throws IOException {
   141     public void write(byte b[]) throws IOException {
   144         write(b, 0, b.length);
   142         write(b, 0, b.length);
   145     }
   143     }
   146 
   144 
   150      *
   148      *
   151      * @param      b     the data.
   149      * @param      b     the data.
   152      * @param      off   the start offset in the data.
   150      * @param      off   the start offset in the data.
   153      * @param      len   the number of bytes to write.
   151      * @param      len   the number of bytes to write.
   154      * @exception  IOException  if an I/O error occurs.
   152      * @exception  IOException  if an I/O error occurs.
   155      * @since      JCE1.2
       
   156      */
   153      */
   157     public void write(byte b[], int off, int len) throws IOException {
   154     public void write(byte b[], int off, int len) throws IOException {
   158         obuffer = cipher.update(b, off, len);
   155         obuffer = cipher.update(b, off, len);
   159         if (obuffer != null) {
   156         if (obuffer != null) {
   160             output.write(obuffer);
   157             output.write(obuffer);
   172      * if the encapsulated cipher is a block cipher, and the total number of
   169      * if the encapsulated cipher is a block cipher, and the total number of
   173      * bytes written using one of the <code>write</code> methods is less than
   170      * bytes written using one of the <code>write</code> methods is less than
   174      * the cipher's block size, no bytes will be written out.
   171      * the cipher's block size, no bytes will be written out.
   175      *
   172      *
   176      * @exception  IOException  if an I/O error occurs.
   173      * @exception  IOException  if an I/O error occurs.
   177      * @since      JCE1.2
       
   178      */
   174      */
   179     public void flush() throws IOException {
   175     public void flush() throws IOException {
   180         if (obuffer != null) {
   176         if (obuffer != null) {
   181             output.write(obuffer);
   177             output.write(obuffer);
   182             obuffer = null;
   178             obuffer = null;
   196      * This method resets the encapsulated cipher object to its initial state
   192      * This method resets the encapsulated cipher object to its initial state
   197      * and calls the <code>close</code> method of the underlying output
   193      * and calls the <code>close</code> method of the underlying output
   198      * stream.
   194      * stream.
   199      *
   195      *
   200      * @exception  IOException  if an I/O error occurs.
   196      * @exception  IOException  if an I/O error occurs.
   201      * @since      JCE1.2
       
   202      */
   197      */
   203     public void close() throws IOException {
   198     public void close() throws IOException {
   204         if (closed) {
   199         if (closed) {
   205             return;
   200             return;
   206         }
   201         }