< prev index next >

src/java.base/share/classes/java/io/OutputStreamWriter.java

Print this page
rev 15357 : imported patch 8163517-Various-cleanup-in-java-io-code


 216     /**
 217      * Writes a portion of a string.
 218      *
 219      * @param  str  A String
 220      * @param  off  Offset from which to start writing characters
 221      * @param  len  Number of characters to write
 222      *
 223      * @throws  IndexOutOfBoundsException
 224      *          If {@code off} is negative, or {@code len} is negative,
 225      *          or {@code off + len} is negative or greater than the length
 226      *          of the given string
 227      *
 228      * @throws  IOException  If an I/O error occurs
 229      */
 230     public void write(String str, int off, int len) throws IOException {
 231         se.write(str, off, len);
 232     }
 233 
 234     @Override
 235     public Writer append(CharSequence csq, int start, int end) throws IOException {
 236         if (csq == null) {
 237             write("null".subSequence(start, end).toString());
 238             return this;
 239         } else {
 240             return append(csq.subSequence(start, end));
 241         }
 242     }
 243 
 244     @Override
 245     public Writer append(CharSequence csq) throws IOException {
 246         if (csq == null) {
 247             se.write("null");
 248         } else if (csq instanceof CharBuffer) {
 249             se.write((CharBuffer) csq);
 250         } else {
 251             se.write(csq.toString());
 252         }
 253         return this;
 254     }
 255 
 256     /**
 257      * Flushes the stream.
 258      *
 259      * @exception  IOException  If an I/O error occurs
 260      */
 261     public void flush() throws IOException {
 262         se.flush();
 263     }
 264 
 265     public void close() throws IOException {
 266         se.close();
 267     }
 268 }


 216     /**
 217      * Writes a portion of a string.
 218      *
 219      * @param  str  A String
 220      * @param  off  Offset from which to start writing characters
 221      * @param  len  Number of characters to write
 222      *
 223      * @throws  IndexOutOfBoundsException
 224      *          If {@code off} is negative, or {@code len} is negative,
 225      *          or {@code off + len} is negative or greater than the length
 226      *          of the given string
 227      *
 228      * @throws  IOException  If an I/O error occurs
 229      */
 230     public void write(String str, int off, int len) throws IOException {
 231         se.write(str, off, len);
 232     }
 233 
 234     @Override
 235     public Writer append(CharSequence csq, int start, int end) throws IOException {
 236         if (csq == null) csq = "null";
 237         write(csq.subSequence(start, end).toString());
 238         return this;



 239     }
 240 
 241     @Override
 242     public Writer append(CharSequence csq) throws IOException {
 243         if (csq instanceof CharBuffer) {


 244             se.write((CharBuffer) csq);
 245         } else {
 246             se.write(String.valueOf(csq));
 247         }
 248         return this;
 249     }
 250 
 251     /**
 252      * Flushes the stream.
 253      *
 254      * @exception  IOException  If an I/O error occurs
 255      */
 256     public void flush() throws IOException {
 257         se.flush();
 258     }
 259 
 260     public void close() throws IOException {
 261         se.close();
 262     }
 263 }
< prev index next >