All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.io.BufferedWriter Maven / Gradle / Ivy

/*

This is not an official specification document, and usage is restricted.

NOTICE


(c) 2005-2007 Sun Microsystems, Inc. All Rights Reserved.

Neither this file nor any files generated from it describe a complete specification, and they may only be used as described below. For example, no permission is given for you to incorporate this file, in whole or in part, in an implementation of a Java specification.

Sun Microsystems Inc. owns the copyright in this file and it is provided to you for informative, as opposed to normative, use. The file and any files generated from it may be used to generate other informative documentation, such as a unified set of documents of API signatures for a platform that includes technologies expressed as Java APIs. The file may also be used to produce "compilation stubs," which allow applications to be compiled and validated for such platforms.

Any work generated from this file, such as unified javadocs or compiled stub files, must be accompanied by this notice in its entirety.

This work corresponds to the API signatures of JSR 219: Foundation Profile 1.1. In the event of a discrepency between this work and the JSR 219 specification, which is available at http://www.jcp.org/en/jsr/detail?id=219, the latter takes precedence. */ package java.io; /** * Write text to a character-output stream, buffering characters so as to * provide for the efficient writing of single characters, arrays, and strings. * *

The buffer size may be specified, or the default size may be accepted. * The default is large enough for most purposes. * *

A newLine() method is provided, which uses the platform's own notion of * line separator as defined by the system property line.separator. * Not all platforms use the newline character ('\n') to terminate lines. * Calling this method to terminate each output line is therefore preferred to * writing a newline character directly. * *

In general, a Writer sends its output immediately to the underlying * character or byte stream. Unless prompt output is required, it is advisable * to wrap a BufferedWriter around any Writer whose write() operations may be * costly, such as FileWriters and OutputStreamWriters. For example, * *

 * PrintWriter out
 *   = new PrintWriter(new BufferedWriter(new FileWriter("foo.out")));
 * 
* * will buffer the PrintWriter's output to the file. Without buffering, each * invocation of a print() method would cause characters to be converted into * bytes that would then be written immediately to the file, which can be very * inefficient. * * @see PrintWriter * @see FileWriter * @see OutputStreamWriter * * @version 1.22, 00/02/02 * @author Mark Reinhold * @since JDK1.1 */ public class BufferedWriter extends Writer { /** * Create a buffered character-output stream that uses a default-sized * output buffer. * * @param out A Writer */ public BufferedWriter(Writer out) { } /** * Create a new buffered character-output stream that uses an output * buffer of the given size. * * @param out A Writer * @param sz Output-buffer size, a positive integer * * @exception IllegalArgumentException If sz is <= 0 */ public BufferedWriter(Writer out, int sz) { } /** * Write a single character. * * @exception IOException If an I/O error occurs */ public void write(int c) throws IOException { } /** * Write a portion of an array of characters. * *

Ordinarily this method stores characters from the given array into * this stream's buffer, flushing the buffer to the underlying stream as * needed. If the requested length is at least as large as the buffer, * however, then this method will flush the buffer and write the characters * directly to the underlying stream. Thus redundant * BufferedWriters will not copy data unnecessarily. * * @param cbuf A character array * @param off Offset from which to start reading characters * @param len Number of characters to write * * @exception IOException If an I/O error occurs */ public void write(char[] cbuf, int off, int len) throws IOException { } /** * Write a portion of a String. * * @param s String to be written * @param off Offset from which to start reading characters * @param len Number of characters to be written * * @exception IOException If an I/O error occurs */ public void write(String s, int off, int len) throws IOException { } /** * Write a line separator. The line separator string is defined by the * system property line.separator, and is not necessarily a single * newline ('\n') character. * * @exception IOException If an I/O error occurs */ public void newLine() throws IOException { } /** * Flush the stream. * * @exception IOException If an I/O error occurs */ public void flush() throws IOException { } /** * Close the stream. * * @exception IOException If an I/O error occurs */ public void close() throws IOException { } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy