public class TextOutputFile
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
closed
Set if the file has been closed.
|
protected java.io.PrintWriter |
f
Streams used for the file
|
protected java.lang.String |
fileName
The file name.
|
protected java.lang.String |
lineSeparator
The line separator in files
|
protected boolean |
useStandardIO
Indicator whether to write to standard output or a file.
|
Constructor and Description |
---|
TextOutputFile()
Contructor - TextOutputFile to write to standard output.
|
TextOutputFile(java.io.File file)
Contructor - TextOutputFile to write to a File.
|
TextOutputFile(java.io.File file,
boolean append)
Contructor - TextOutputFile to write or append to a File.
|
TextOutputFile(java.lang.String fileName)
Contructor - TextFile to write to file with specified name.
|
TextOutputFile(java.lang.String fileName,
boolean append)
Contructor - TextFile to write or append to file with specified name.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the file to further writing.
|
boolean |
isStandardOut() |
void |
print(boolean value)
Write the text representation of a boolean to the file.
|
void |
print(boolean value,
int fieldSize)
Write the text representation of a boolean to the file with a
specified field size.
|
void |
print(byte number)
Write the text representation of an 8-bit integer (a "byte") to
the file.
|
void |
print(byte number,
int fieldSize)
Write the text representation of an 8-bit integer (a "byte")
to the file with a specified field size.
|
void |
print(char ch)
Write a character to the file.
|
void |
print(char ch,
int fieldSize)
Write a character to the file with a specified field size..
|
void |
print(double number)
Write a double precision floating point number (a "double") to
the file.
|
void |
print(double number,
int fieldSize)
Write a double precision floating point number (a "double") to
the file with a specified field size.
|
void |
print(double number,
int fieldSize,
int decimalPlaces)
Write a double precision floating point number (a "double") to
the file with a specified field size and a specified number of
decimal places.
|
void |
print(float number)
Write a floating point number (a "float") to the file.
|
void |
print(float number,
int fieldSize)
Write a floating point number (a "float") to
the file with a specified field size.
|
void |
print(float number,
int fieldSize,
int decimalPlaces)
Write a floating point number (a "double") to the file with a
specified field size and a specified number of decimal places.
|
void |
print(int number)
Write the text representation of an 32-bit integer (an "int") to
the file.
|
void |
print(int number,
int fieldSize)
Write the text representation of an 32-bit integer (an "int")
to the file with a specified field size.
|
void |
print(long number)
Write the text representation of an 64-bit integer (a "long") to
the file.
|
void |
print(long number,
int fieldSize)
Write the text representation of an 64-bit integer (a "long")
to the file with a specified field size.
|
void |
print(short number)
Write the text representation of an 16-bit integer (a "short") to
the file.
|
void |
print(short number,
int fieldSize)
Write the text representation of an 16-bit integer (a "short")
to the file with a specified field size.
|
void |
print(java.lang.String text)
Write a string to the file.
|
void |
print(java.lang.String text,
int fieldSize)
Write a string to the file with a specified field size..
|
void |
println()
Write a newline to the file.
|
void |
println(boolean value)
Write the text representation of a boolean to the file followed
by a newline.
|
void |
println(boolean value,
int fieldSize)
Write the text representation of a boolean to the file with a
specified field size followed by a newline.
|
void |
println(byte number)
Write the text representation of an 8-bit integer (a "byte") to
the file followed by a newline.
|
void |
println(byte number,
int fieldSize)
Write the text representation of an 8-bit integer (a "byte")
to the file with a specified field size followed by a newline.
|
void |
println(char ch)
Write a character to the file followed by a newline.
|
void |
println(char ch,
int fieldSize)
Write a character to the file with a specified field size..
|
void |
println(double number)
Write a double precision floating point number (a "double") to
the file followed by a newline.
|
void |
println(double number,
int fieldSize)
Write a double precision floating point number (a "double") to
the file with a specified field size followed by a newline.
|
void |
println(double number,
int fieldSize,
int decimalPlaces)
Write a double precision floating point number (a "double") to
the file with a specified field size and a specified number of
decimal places followed by a newline.
|
void |
println(float number)
Write a floating point number (a "float") to the file followed by
a newline.
|
void |
println(float number,
int fieldSize)
Write a floating point number (a "float") to the file with a
specified field size followed by a newline.
|
void |
println(float number,
int fieldSize,
int decimalPlaces)
Write a floating point number (a "double") to the file with a
specified field size and a specified number of decimal places
followed by a newline.
|
void |
println(int number)
Write the text representation of an 32-bit integer (an "int") to
the file followed by a newline.
|
void |
println(int number,
int fieldSize)
Write the text representation of an 32-bit integer (an "int")
to the file with a specified field size followed by a newline.
|
void |
println(long number)
Write the text representation of an 64-bit integer (a "long") to
the file followed by a newline.
|
void |
println(long number,
int fieldSize)
Write the text representation of an 64-bit integer (a "long")
to the file with a specified field size followed by a newline.
|
void |
println(short number)
Write the text representation of an 16-bit integer (a "short") to
the file followed by a newline.
|
void |
println(short number,
int fieldSize)
Write the text representation of an 16-bit integer (a "short")
to the file with a specified field size followed by a newline.
|
void |
println(java.lang.String text)
Write a string to the file followed by a newline.
|
void |
println(java.lang.String text,
int fieldSize)
Write a string to the file with a specified field size followed by
a newline.
|
protected java.lang.String fileName
protected java.io.PrintWriter f
protected boolean closed
protected boolean useStandardIO
protected java.lang.String lineSeparator
public TextOutputFile()
public TextOutputFile(java.io.File file)
file
- - File to be opened.public TextOutputFile(java.io.File file, boolean append)
file
- - File to be opened.append
- - True if file is to be appended to.public TextOutputFile(java.lang.String fileName)
fileName
- - Name of the file to be opened.public TextOutputFile(java.lang.String fileName, boolean append)
fileName
- - Name of the file to be opened.append
- - True if file is to be appended to.public void close()
public boolean isStandardOut()
public void print(byte number)
number
- The number to be written to the file.public void print(byte number, int fieldSize)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.public void print(char ch)
ch
- The character to be written to the file.public void print(char ch, int fieldSize)
ch
- The character to be written to the file.fieldSize
- The field width that the character is to be written in.public void print(double number)
number
- The number to be written to the file.public void print(double number, int fieldSize)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.public void print(double number, int fieldSize, int decimalPlaces)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.decimalPlaces
- The number of decimal places of the number
to be displayed.public void print(float number)
number
- The number to be written to the file.public void print(float number, int fieldSize)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.public void print(float number, int fieldSize, int decimalPlaces)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.decimalPlaces
- The number of decimal places of the number
to be displayed.public void print(int number)
number
- The number to be written to the file.public void print(int number, int fieldSize)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.public void print(long number)
number
- The number to be written to the file.public void print(long number, int fieldSize)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.public void print(java.lang.String text)
text
- The string to be written to the file.public void print(java.lang.String text, int fieldSize)
text
- The string to be written to the file.fieldSize
- The field width that the string is to be written in.public void print(short number)
number
- The number to be written to the file.public void print(short number, int fieldSize)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.public void print(boolean value)
value
- The boolean to be written to the file.public void print(boolean value, int fieldSize)
value
- The boolean to be written to the file.fieldSize
- The field width that the boolean is to be written in.public void println()
public void println(byte number)
number
- The number to be written to the file.public void println(byte number, int fieldSize)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.public void println(char ch)
ch
- The character to be written to the file.public void println(char ch, int fieldSize)
ch
- The character to be written to the file.fieldSize
- The field width that the character is to be written in.public void println(double number)
number
- The number to be written to the file.public void println(double number, int fieldSize)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.public void println(double number, int fieldSize, int decimalPlaces)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.decimalPlaces
- The number of decimal places of the number
to be displayed.public void println(float number)
number
- The number to be written to the file.public void println(float number, int fieldSize)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.public void println(float number, int fieldSize, int decimalPlaces)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.decimalPlaces
- The number of decimal places of the number
to be displayed.public void println(int number)
number
- The number to be written to the file.public void println(int number, int fieldSize)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.public void println(long number)
number
- The number to be written to the file.public void println(long number, int fieldSize)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.public void println(java.lang.String text)
text
- The string to be written to the file.public void println(java.lang.String text, int fieldSize)
text
- The string to be written to the file.fieldSize
- The field width that the string is to be written in.public void println(short number)
number
- The number to be written to the file.public void println(short number, int fieldSize)
number
- The number to be written to the file.fieldSize
- The field width that the number is to be written in.public void println(boolean value)
value
- The boolean to be written to the file.public void println(boolean value, int fieldSize)
value
- The boolean to be written to the file.fieldSize
- The field width that the boolean is to be written in.