Partager via


PrintWriter Constructors

Definition

Overloads

PrintWriter(File)

Creates a new PrintWriter, without automatic line flushing, with the specified file.

PrintWriter(Writer)

Creates a new PrintWriter, without automatic line flushing.

PrintWriter(Stream)

Creates a new PrintWriter, without automatic line flushing, from an existing OutputStream.

PrintWriter(String)

Creates a new PrintWriter, without automatic line flushing, with the specified file name.

PrintWriter(File, Charset)

Creates a new PrintWriter, without automatic line flushing, with the specified file and charset.

PrintWriter(File, String)

Creates a new PrintWriter, without automatic line flushing, with the specified file and charset.

PrintWriter(Writer, Boolean)

Creates a new PrintWriter.

PrintWriter(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

PrintWriter(Stream, Boolean)

Creates a new PrintWriter from an existing OutputStream.

PrintWriter(String, Charset)

Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset.

PrintWriter(String, String)

Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset.

PrintWriter(Stream, Boolean, Charset)

Creates a new PrintWriter from an existing OutputStream.

PrintWriter(File)

Creates a new PrintWriter, without automatic line flushing, with the specified file.

[Android.Runtime.Register(".ctor", "(Ljava/io/File;)V", "")]
public PrintWriter (Java.IO.File file);
[<Android.Runtime.Register(".ctor", "(Ljava/io/File;)V", "")>]
new Java.IO.PrintWriter : Java.IO.File -> Java.IO.PrintWriter

Parameters

file
File

The file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.

Attributes

Exceptions

if an error occurs while opening or creating the target file.

Remarks

Creates a new PrintWriter, without automatic line flushing, with the specified file. This convenience constructor creates the necessary intermediate java.io.OutputStreamWriter OutputStreamWriter, which will encode characters using the java.nio.charset.Charset#defaultCharset() default charset for this instance of the Java virtual machine.

Added in 1.5.

Java documentation for java.io.PrintWriter.PrintWriter(java.io.File).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

PrintWriter(Writer)

Creates a new PrintWriter, without automatic line flushing.

[Android.Runtime.Register(".ctor", "(Ljava/io/Writer;)V", "")]
public PrintWriter (Java.IO.Writer out);
[<Android.Runtime.Register(".ctor", "(Ljava/io/Writer;)V", "")>]
new Java.IO.PrintWriter : Java.IO.Writer -> Java.IO.PrintWriter

Parameters

out
Writer

A character-output stream

Attributes

Exceptions

if wr is null.

Remarks

Creates a new PrintWriter, without automatic line flushing.

Java documentation for java.io.PrintWriter.PrintWriter(java.io.Writer).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

PrintWriter(Stream)

Creates a new PrintWriter, without automatic line flushing, from an existing OutputStream.

[Android.Runtime.Register(".ctor", "(Ljava/io/OutputStream;)V", "")]
public PrintWriter (System.IO.Stream out);
[<Android.Runtime.Register(".ctor", "(Ljava/io/OutputStream;)V", "")>]
new Java.IO.PrintWriter : System.IO.Stream -> Java.IO.PrintWriter

Parameters

out
Stream

An output stream

Attributes

Exceptions

if out is null.

Remarks

Creates a new PrintWriter, without automatic line flushing, from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the default character encoding.

Java documentation for java.io.PrintWriter.PrintWriter(java.io.OutputStream).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

PrintWriter(String)

Creates a new PrintWriter, without automatic line flushing, with the specified file name.

[Android.Runtime.Register(".ctor", "(Ljava/lang/String;)V", "")]
public PrintWriter (string fileName);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;)V", "")>]
new Java.IO.PrintWriter : string -> Java.IO.PrintWriter

Parameters

fileName
String

The name of the file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.

Attributes

Exceptions

if an error occurs while opening or creating the target file.

Remarks

Creates a new PrintWriter, without automatic line flushing, with the specified file name. This convenience constructor creates the necessary intermediate java.io.OutputStreamWriter OutputStreamWriter, which will encode characters using the java.nio.charset.Charset#defaultCharset() default charset for this instance of the Java virtual machine.

Added in 1.5.

Java documentation for java.io.PrintWriter.PrintWriter(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

PrintWriter(File, Charset)

Creates a new PrintWriter, without automatic line flushing, with the specified file and charset.

[Android.Runtime.Register(".ctor", "(Ljava/io/File;Ljava/nio/charset/Charset;)V", "", ApiSince=33)]
public PrintWriter (Java.IO.File file, Java.Nio.Charset.Charset charset);
[<Android.Runtime.Register(".ctor", "(Ljava/io/File;Ljava/nio/charset/Charset;)V", "", ApiSince=33)>]
new Java.IO.PrintWriter : Java.IO.File * Java.Nio.Charset.Charset -> Java.IO.PrintWriter

Parameters

file
File

The file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.

charset
Charset

A java.nio.charset.Charset charset

Attributes

Remarks

Creates a new PrintWriter, without automatic line flushing, with the specified file and charset. This convenience constructor creates the necessary intermediate java.io.OutputStreamWriter OutputStreamWriter, which will encode characters using the provided charset.

Added in 10.

Java documentation for java.io.PrintWriter.PrintWriter(java.io.File, java.nio.charset.Charset).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

PrintWriter(File, String)

Creates a new PrintWriter, without automatic line flushing, with the specified file and charset.

[Android.Runtime.Register(".ctor", "(Ljava/io/File;Ljava/lang/String;)V", "")]
public PrintWriter (Java.IO.File file, string csn);
[<Android.Runtime.Register(".ctor", "(Ljava/io/File;Ljava/lang/String;)V", "")>]
new Java.IO.PrintWriter : Java.IO.File * string -> Java.IO.PrintWriter

Parameters

file
File

The file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.

csn
String

The name of a supported java.nio.charset.Charset charset

Attributes

Exceptions

if an error occurs while opening or creating the target file.

if csn is null.

if the encoding specified by csn is not supported.

Remarks

Creates a new PrintWriter, without automatic line flushing, with the specified file and charset. This convenience constructor creates the necessary intermediate java.io.OutputStreamWriter OutputStreamWriter, which will encode characters using the provided charset.

Added in 1.5.

Java documentation for java.io.PrintWriter.PrintWriter(java.io.File, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

PrintWriter(Writer, Boolean)

Creates a new PrintWriter.

[Android.Runtime.Register(".ctor", "(Ljava/io/Writer;Z)V", "")]
public PrintWriter (Java.IO.Writer out, bool autoFlush);
[<Android.Runtime.Register(".ctor", "(Ljava/io/Writer;Z)V", "")>]
new Java.IO.PrintWriter : Java.IO.Writer * bool -> Java.IO.PrintWriter

Parameters

out
Writer

A character-output stream

autoFlush
Boolean

A boolean; if true, the println, printf, or format methods will flush the output buffer

Attributes

Exceptions

if out is null.

Remarks

Creates a new PrintWriter.

Java documentation for java.io.PrintWriter.PrintWriter(java.io.Writer, boolean).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

PrintWriter(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

protected PrintWriter (IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);
new Java.IO.PrintWriter : nativeint * Android.Runtime.JniHandleOwnership -> Java.IO.PrintWriter

Parameters

javaReference
IntPtr

nativeint

A IntPtrcontaining a Java Native Interface (JNI) object reference.

transfer
JniHandleOwnership

A JniHandleOwnershipindicating how to handle javaReference

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

PrintWriter(Stream, Boolean)

Creates a new PrintWriter from an existing OutputStream.

[Android.Runtime.Register(".ctor", "(Ljava/io/OutputStream;Z)V", "")]
public PrintWriter (System.IO.Stream out, bool autoFlush);
[<Android.Runtime.Register(".ctor", "(Ljava/io/OutputStream;Z)V", "")>]
new Java.IO.PrintWriter : System.IO.Stream * bool -> Java.IO.PrintWriter

Parameters

out
Stream

An output stream

autoFlush
Boolean

A boolean; if true, the println, printf, or format methods will flush the output buffer

Attributes

Exceptions

if out is null.

Remarks

Creates a new PrintWriter from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the default character encoding.

Java documentation for java.io.PrintWriter.PrintWriter(java.io.OutputStream, boolean).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

PrintWriter(String, Charset)

Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset.

[Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/nio/charset/Charset;)V", "", ApiSince=33)]
public PrintWriter (string fileName, Java.Nio.Charset.Charset charset);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/nio/charset/Charset;)V", "", ApiSince=33)>]
new Java.IO.PrintWriter : string * Java.Nio.Charset.Charset -> Java.IO.PrintWriter

Parameters

fileName
String

The name of the file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.

charset
Charset

A java.nio.charset.Charset charset

Attributes

Remarks

Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset. This convenience constructor creates the necessary intermediate java.io.OutputStreamWriter OutputStreamWriter, which will encode characters using the provided charset.

Added in 10.

Java documentation for java.io.PrintWriter.PrintWriter(java.lang.String, java.nio.charset.Charset).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

PrintWriter(String, String)

Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset.

[Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/lang/String;)V", "")]
public PrintWriter (string fileName, string csn);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/lang/String;)V", "")>]
new Java.IO.PrintWriter : string * string -> Java.IO.PrintWriter

Parameters

fileName
String

The name of the file to use as the destination of this writer. If the file exists then it will be truncated to zero size; otherwise, a new file will be created. The output will be written to the file and is buffered.

csn
String

The name of a supported java.nio.charset.Charset charset

Attributes

Exceptions

if an error occurs while opening or creating the target file.

if csn is null.

if the encoding specified by csn is not supported.

Remarks

Creates a new PrintWriter, without automatic line flushing, with the specified file name and charset. This convenience constructor creates the necessary intermediate java.io.OutputStreamWriter OutputStreamWriter, which will encode characters using the provided charset.

Added in 1.5.

Java documentation for java.io.PrintWriter.PrintWriter(java.lang.String, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

PrintWriter(Stream, Boolean, Charset)

Creates a new PrintWriter from an existing OutputStream.

[Android.Runtime.Register(".ctor", "(Ljava/io/OutputStream;ZLjava/nio/charset/Charset;)V", "", ApiSince=33)]
public PrintWriter (System.IO.Stream out, bool autoFlush, Java.Nio.Charset.Charset charset);
[<Android.Runtime.Register(".ctor", "(Ljava/io/OutputStream;ZLjava/nio/charset/Charset;)V", "", ApiSince=33)>]
new Java.IO.PrintWriter : System.IO.Stream * bool * Java.Nio.Charset.Charset -> Java.IO.PrintWriter

Parameters

out
Stream

An output stream

autoFlush
Boolean

A boolean; if true, the println, printf, or format methods will flush the output buffer

charset
Charset

A java.nio.charset.Charset charset

Attributes

Remarks

Creates a new PrintWriter from an existing OutputStream. This convenience constructor creates the necessary intermediate OutputStreamWriter, which will convert characters into bytes using the specified charset.

Added in 10.

Java documentation for java.io.PrintWriter.PrintWriter(java.io.OutputStream, boolean, java.nio.charset.Charset).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to