< prev index next >

src/java.base/share/classes/java/net/SocketOutputStream.java

Print this page
rev 56290 : 8230648: Replace @exception tag with @throws in java.base
Summary: Minor coding style update of javadoc tag in any file in java.base
Reviewed-by: prappo, lancea


  62      * object associated with this file output stream. </p>
  63      *
  64      * The {@code getChannel} method of {@code SocketOutputStream}
  65      * returns {@code null} since it is a socket based stream.</p>
  66      *
  67      * @return  the file channel associated with this file output stream
  68      *
  69      * @since 1.4
  70      * @spec JSR-51
  71      */
  72     public final FileChannel getChannel() {
  73         return null;
  74     }
  75 
  76     /**
  77      * Writes to the socket.
  78      * @param fd the FileDescriptor
  79      * @param b the data to be written
  80      * @param off the start offset in the data
  81      * @param len the number of bytes that are written
  82      * @exception IOException If an I/O error has occurred.
  83      */
  84     private native void socketWrite0(FileDescriptor fd, byte[] b, int off,
  85                                      int len) throws IOException;
  86 
  87     /**
  88      * Writes to the socket with appropriate locking of the
  89      * FileDescriptor.
  90      * @param b the data to be written
  91      * @param off the start offset in the data
  92      * @param len the number of bytes that are written
  93      * @exception IOException If an I/O error has occurred.
  94      */
  95     private void socketWrite(byte b[], int off, int len) throws IOException {
  96 
  97 
  98         if (len <= 0 || off < 0 || len > b.length - off) {
  99             if (len == 0) {
 100                 return;
 101             }
 102             throw new ArrayIndexOutOfBoundsException("len == " + len
 103                     + " off == " + off + " buffer length == " + b.length);
 104         }
 105 
 106         FileDescriptor fd = impl.acquireFD();
 107         try {
 108             socketWrite0(fd, b, off, len);
 109         } catch (SocketException se) {
 110             if (impl.isClosedOrPending()) {
 111                 throw new SocketException("Socket closed");
 112             } else {
 113                 throw se;
 114             }
 115         } finally {
 116             impl.releaseFD();
 117         }
 118     }
 119 
 120     /**
 121      * Writes a byte to the socket.
 122      * @param b the data to be written
 123      * @exception IOException If an I/O error has occurred.
 124      */
 125     public void write(int b) throws IOException {
 126         temp[0] = (byte)b;
 127         socketWrite(temp, 0, 1);
 128     }
 129 
 130     /**
 131      * Writes the contents of the buffer <i>b</i> to the socket.
 132      * @param b the data to be written
 133      * @exception SocketException If an I/O error has occurred.
 134      */
 135     public void write(byte b[]) throws IOException {
 136         socketWrite(b, 0, b.length);
 137     }
 138 
 139     /**
 140      * Writes <i>length</i> bytes from buffer <i>b</i> starting at
 141      * offset <i>len</i>.
 142      * @param b the data to be written
 143      * @param off the start offset in the data
 144      * @param len the number of bytes that are written
 145      * @exception SocketException If an I/O error has occurred.
 146      */
 147     public void write(byte b[], int off, int len) throws IOException {
 148         socketWrite(b, off, len);
 149     }
 150 
 151     public void close() throws IOException {
 152         // No longer used. Socket.getOutputStream returns an
 153         // OutputStream which calls Socket.close directly
 154         assert false;
 155     }
 156 
 157     /**
 158      * Overrides finalize, the fd is closed by the Socket.
 159      */
 160     @SuppressWarnings({"deprecation", "removal"})
 161     protected void finalize() {}
 162 
 163     /**
 164      * Perform class load-time initializations.
 165      */


  62      * object associated with this file output stream. </p>
  63      *
  64      * The {@code getChannel} method of {@code SocketOutputStream}
  65      * returns {@code null} since it is a socket based stream.</p>
  66      *
  67      * @return  the file channel associated with this file output stream
  68      *
  69      * @since 1.4
  70      * @spec JSR-51
  71      */
  72     public final FileChannel getChannel() {
  73         return null;
  74     }
  75 
  76     /**
  77      * Writes to the socket.
  78      * @param fd the FileDescriptor
  79      * @param b the data to be written
  80      * @param off the start offset in the data
  81      * @param len the number of bytes that are written
  82      * @throws    IOException If an I/O error has occurred.
  83      */
  84     private native void socketWrite0(FileDescriptor fd, byte[] b, int off,
  85                                      int len) throws IOException;
  86 
  87     /**
  88      * Writes to the socket with appropriate locking of the
  89      * FileDescriptor.
  90      * @param b the data to be written
  91      * @param off the start offset in the data
  92      * @param len the number of bytes that are written
  93      * @throws    IOException If an I/O error has occurred.
  94      */
  95     private void socketWrite(byte b[], int off, int len) throws IOException {
  96 
  97 
  98         if (len <= 0 || off < 0 || len > b.length - off) {
  99             if (len == 0) {
 100                 return;
 101             }
 102             throw new ArrayIndexOutOfBoundsException("len == " + len
 103                     + " off == " + off + " buffer length == " + b.length);
 104         }
 105 
 106         FileDescriptor fd = impl.acquireFD();
 107         try {
 108             socketWrite0(fd, b, off, len);
 109         } catch (SocketException se) {
 110             if (impl.isClosedOrPending()) {
 111                 throw new SocketException("Socket closed");
 112             } else {
 113                 throw se;
 114             }
 115         } finally {
 116             impl.releaseFD();
 117         }
 118     }
 119 
 120     /**
 121      * Writes a byte to the socket.
 122      * @param b the data to be written
 123      * @throws    IOException If an I/O error has occurred.
 124      */
 125     public void write(int b) throws IOException {
 126         temp[0] = (byte)b;
 127         socketWrite(temp, 0, 1);
 128     }
 129 
 130     /**
 131      * Writes the contents of the buffer <i>b</i> to the socket.
 132      * @param b the data to be written
 133      * @throws    SocketException If an I/O error has occurred.
 134      */
 135     public void write(byte b[]) throws IOException {
 136         socketWrite(b, 0, b.length);
 137     }
 138 
 139     /**
 140      * Writes <i>length</i> bytes from buffer <i>b</i> starting at
 141      * offset <i>len</i>.
 142      * @param b the data to be written
 143      * @param off the start offset in the data
 144      * @param len the number of bytes that are written
 145      * @throws    SocketException If an I/O error has occurred.
 146      */
 147     public void write(byte b[], int off, int len) throws IOException {
 148         socketWrite(b, off, len);
 149     }
 150 
 151     public void close() throws IOException {
 152         // No longer used. Socket.getOutputStream returns an
 153         // OutputStream which calls Socket.close directly
 154         assert false;
 155     }
 156 
 157     /**
 158      * Overrides finalize, the fd is closed by the Socket.
 159      */
 160     @SuppressWarnings({"deprecation", "removal"})
 161     protected void finalize() {}
 162 
 163     /**
 164      * Perform class load-time initializations.
 165      */
< prev index next >