Package org.svetovid.io
Interface SvetovidWriter
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
AbstractSvetovidWriter
,DefaultSvetovidWriter
,StandardSvetovidErrorWriter
,StandardSvetovidWriter
This interface provides methods that simplify outputting data for beginner
programmers. Exception handling is not necessary as it can be turned on or
off by using
setThrowingExceptions(boolean)
. Even when the exception
throwing is turned off, if necessary, the last raised exception can be
retrieved using getLastException()
method.-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this writer and releases any resources associated with the underlying stream.boolean
Returns whether this writer automatically flushes the underlying output stream and forces any buffered output bytes to be written out after every operation by callingprintbf()
.Returns the exception raised in the last operation; if the operation was successful and no exception was raised, returnsnull
.Returns the currently used whitespace.boolean
Returns the indicator whether this writer will throw exceptions on I/O operation errors or just return default values.void
print()
Prints a whitespace.void
print
(boolean value) Prints a boolean value as a human readable string.void
print
(byte value) Prints a byte value as a human readable string.void
print
(char value) Prints a character value as a human readable string.void
print
(double value) Prints a double-precision floating-point value as a human readable string.void
print
(float value) Prints a floating-point value as a human readable string.void
print
(int value) Prints an integer value as a human readable string.void
print
(long value) Prints a long integer value as a human readable string.void
print
(short value) Prints a short integer value as a human readable string.void
Prints an object as a human readable string.void
Prints a string.void
printbf()
Prints any buffered data to the underlying output stream and then flushes that stream.void
Prints a formatted string using the specified format string and arguments.void
println()
Prints a line separator as defined by theline.separator
system property.void
println
(boolean value) Prints a boolean value and then terminates the line.void
println
(boolean... values) Prints all given boolean values in sequence separated by whitespace and then terminates the line.void
println
(boolean[][] value) Prints the given boolean matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
println
(byte value) Prints a byte value and then terminates the line.void
println
(byte... values) Prints all given byte values in sequence separated by whitespace and then terminates the line.void
println
(byte[][] value) Prints the given byte matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
println
(char value) Prints a character value and then terminates the line.void
println
(char... values) Prints all given character values in sequence separated by whitespace and then terminates the line.void
println
(char[][] value) Prints the given character matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
println
(double value) Prints a double-precision floating-point value and then terminates the line.void
println
(double... values) Prints all given double-precision floating-point values in sequence separated by whitespace and then terminates the line.void
println
(double[][] value) Prints the given double-precision floating-point matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
println
(float value) Prints a floating-point value and then terminates the line.void
println
(float... values) Prints all given floating-point values in sequence separated by whitespace and then terminates the line.void
println
(float[][] value) Prints the given floating-point matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
println
(int value) Prints an integer value and then terminates the line.void
println
(int... values) Prints all given integer values in sequence separated by whitespace and then terminates the line.void
println
(int[][] value) Prints the given integer matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
println
(long value) Prints a long integer value and then terminates the line.void
println
(long... values) Prints all given long integer values in sequence separated by whitespace and then terminates the line.void
println
(long[][] value) Prints the given long integer matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
println
(short value) Prints a short integer value and then terminates the line.void
println
(short... values) Prints all given short integer values in sequence separated by whitespace and then terminates the line.void
println
(short[][] value) Prints the given short integer matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
Prints all given boolean values in sequence separated by whitespace and then terminates the line.void
Prints the given boolean matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
Prints all given byte values in sequence separated by whitespace and then terminates the line.void
Prints the given byte matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
Prints all given character values in sequence separated by whitespace and then terminates the line.void
Prints the given character matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
Prints all given double-precision floating-point values in sequence separated by whitespace and then terminates the line.void
Prints the given double-precision floating-point matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
Prints all given floating-point values in sequence separated by whitespace and then terminates the line.void
Prints the given floating-point matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
Prints all given integer values in sequence separated by whitespace and then terminates the line.void
Prints the given integer matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
Prints all given long integer values in sequence separated by whitespace and then terminates the line.void
Prints the given long integer matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
Prints an object and then terminates the line.void
Prints all given objects in sequence separated by whitespace and then terminates the line.void
Prints the given object matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
Prints all given short integer values in sequence separated by whitespace and then terminates the line.void
Prints the given short integer matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
Prints a string and then terminates the line.void
Prints all given string values in sequence separated by whitespace and then terminates the line.void
Prints the given string matrix row by row, each in the separate line, with the individual elements separated by whitespace.void
printObject
(Object value) Prints the given object in JSON (JavaScript Object Notation) format.void
setAutoFlush
(boolean autoFlush) Configures whether this writer should automatically flush the underlying output stream and force any buffered output bytes to be written out after every operation by callingprintbf()
.void
setThrowingExceptions
(boolean shouldThrow) Configures whether this writer should throw exceptions on I/O operation errors or just return default values.void
setWhitespace
(String whitespace) Sets the string used as whitespace.
-
Method Details
-
getWhitespace
String getWhitespace()Returns the currently used whitespace. This whitespace is written by methods likeprint()
andprintln(Object[])
.- Returns:
- the string currently used as whitespace.
-
setWhitespace
Sets the string used as whitespace. This whitespace is written by methods likeprint()
andprintln(Object[])
.- Parameters:
whitespace
- the string to use as whitespace
-
getAutoFlush
boolean getAutoFlush()Returns whether this writer automatically flushes the underlying output stream and forces any buffered output bytes to be written out after every operation by callingprintbf()
.- Returns:
true
if this writer automatically flushes the underlying output stream;false
otherwise.
-
setAutoFlush
void setAutoFlush(boolean autoFlush) Configures whether this writer should automatically flush the underlying output stream and force any buffered output bytes to be written out after every operation by callingprintbf()
.- Parameters:
autoFlush
- iftrue
this writer will callprintbf()
after every operation
-
isThrowingExceptions
boolean isThrowingExceptions()Returns the indicator whether this writer will throw exceptions on I/O operation errors or just return default values.- Returns:
true
if this writer throws exceptions on failed I/O operations;false
otherwise.
-
setThrowingExceptions
void setThrowingExceptions(boolean shouldThrow) Configures whether this writer should throw exceptions on I/O operation errors or just return default values.- Parameters:
shouldThrow
-true
if this writer should throw exceptions on failed I/O operations in the future;false
if it should return default values.
-
getLastException
Throwable getLastException()Returns the exception raised in the last operation; if the operation was successful and no exception was raised, returnsnull
.- Returns:
- the exception raised in the last operation or
null
it the operation was successful.
-
close
Closes this writer and releases any resources associated with the underlying stream. The general contract ofclose
is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
print
Prints a boolean value as a human readable string.- Parameters:
value
- Theboolean
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
print
Prints a byte value as a human readable string.- Parameters:
value
- Thebyte
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
print
Prints a short integer value as a human readable string.- Parameters:
value
- Theshort
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
print
Prints an integer value as a human readable string.- Parameters:
value
- Theinteger
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
print
Prints a long integer value as a human readable string.- Parameters:
value
- Thelong
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
print
Prints a floating-point value as a human readable string.- Parameters:
value
- Thefloat
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
print
Prints a double-precision floating-point value as a human readable string.- Parameters:
value
- Thedouble
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
print
Prints a character value as a human readable string.- Parameters:
value
- Thecharacter
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
print
Prints a string. If the argument isnull
then the string"null"
is printed.- Parameters:
value
- TheString
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
print
Prints an object as a human readable string.- Parameters:
value
- TheObject
to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
print
Prints a whitespace.- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
printbf
Prints any buffered data to the underlying output stream and then flushes that stream.- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints a boolean value and then terminates the line. This method behaves as though it invokesprint(boolean)
and thenprintln()
.- Parameters:
value
- Theboolean
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints a byte value and then terminates the line. This method behaves as though it invokesprint(byte)
and thenprintln()
.- Parameters:
value
- Thebyte
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints a short integer value and then terminates the line. This method behaves as though it invokesprint(short)
and thenprintln()
.- Parameters:
value
- Theshort
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints an integer value and then terminates the line. This method behaves as though it invokesprint(int)
and thenprintln()
.- Parameters:
value
- Theinteger
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints a long integer value and then terminates the line. This method behaves as though it invokesprint(long)
and thenprintln()
.- Parameters:
value
- Thelong
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints a floating-point value and then terminates the line. This method behaves as though it invokesprint(float)
and thenprintln()
.println()
.- Parameters:
value
- Thefloat
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints a double-precision floating-point value and then terminates the line. This method behaves as though it invokesprint(double)
and thenprintln()
.- Parameters:
value
- Thedouble
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints a character value and then terminates the line. This method behaves as though it invokesprint(char)
and thenprintln()
.- Parameters:
value
- Thecharacter
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints a string and then terminates the line. This method behaves as though it invokesprint(String)
and thenprintln()
.- Parameters:
value
- TheString
value to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints an object and then terminates the line. This method behaves as though it invokesprint(Object)
and thenprintln()
.- Parameters:
value
- TheObject
to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints a line separator as defined by theline.separator
system property.- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given boolean values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprint(boolean)
for each of the given values invokingprint()
in-between andprintln()
at the end.- Parameters:
values
- Theboolean
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given byte values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprint(byte)
for each of the given values invokingprint()
in-between andprintln()
at the end.- Parameters:
values
- Thebyte
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given short integer values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprint(short)
for each of the given values invokingprint()
in-between andprintln()
at the end.- Parameters:
values
- Theshort
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given integer values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprint(int)
for each of the given values invokingprint()
in-between andprintln()
at the end.- Parameters:
values
- Theint
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given long integer values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprint(long)
for each of the given values invokingprint()
in-between andprintln()
at the end.- Parameters:
values
- Thelong
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given floating-point values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprint(float)
for each of the given values invokingprint()
in-between andprintln()
at the end.- Parameters:
values
- Thefloat
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given double-precision floating-point values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprint(double)
for each of the given values invokingprint()
in-between andprintln()
at the end.- Parameters:
values
- Thedouble
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given character values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprint(char)
for each of the given values invokingprint()
in-between andprintln()
at the end.- Parameters:
values
- Thechar
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given boolean values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprintln(Object[])
.- Parameters:
values
- TheBoolean
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given byte values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprintln(Object[])
.- Parameters:
values
- TheByte
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given short integer values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprintln(Object[])
.- Parameters:
values
- TheShort
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given integer values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprintln(Object[])
.- Parameters:
values
- TheInteger
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given long integer values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprintln(Object[])
.- Parameters:
values
- TheLong
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given floating-point values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprintln(Object[])
.- Parameters:
values
- TheFloat
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given double-precision floating-point values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprintln(Object[])
.- Parameters:
values
- TheDouble
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given character values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprintln(Object[])
.- Parameters:
values
- TheCharacter
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given string values in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprint(String)
for each of the given values invokingprint()
in-between andprintln()
at the end.- Parameters:
values
- TheString
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints all given objects in sequence separated by whitespace and then terminates the line. This method behaves as though it invokesprint(Object)
for each of the given values invokingprint()
in-between andprintln()
at the end.- Parameters:
values
- TheObject
values to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given boolean matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- Theboolean
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given byte matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- Thebyte
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given short integer matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- Theshort
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given integer matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- Theint
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given long integer matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- Thelong
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given floating-point matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- Thefloat
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given double-precision floating-point matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- Thedouble
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given character matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- Thechar
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given boolean matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- TheBoolean
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given byte matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- TheByte
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given short integer matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- TheShort
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given integer matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- TheInteger
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given long integer matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- TheLong
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given floating-point matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- TheFloat
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given double-precision floating-point matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- TheDouble
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given character matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- TheCharacter
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given string matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- TheString
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
println
Prints the given object matrix row by row, each in the separate line, with the individual elements separated by whitespace.- Parameters:
value
- TheObject
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-
printf
Prints a formatted string using the specified format string and arguments. For details seeFormatter
.- Parameters:
format
- A format string as described inFormatter
string syntax.arguments
- Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. The behavior on a null argument depends on the conversion.- Throws:
SvetovidFormatException
- If a format string isnull
, contains an illegal syntax, a format specifier that is incompatible with the given arguments, insufficient arguments given the format string, or other illegal conditions. For specification of all possible formatting errors, see the Details section of theFormatter
class specification.SvetovidIOException
- if an error occurred during the operation.
-
printObject
Prints the given object in JSON (JavaScript Object Notation) format.The object is printed using the following rules:
null
is printed as JSONnull
literal,- Boxed
true
andfalse
values are printed as JSON literalstrue
andfalse
respectively, Number
instances are printed as JSON number literals,String
values are printed as JSON string literals,- arrays and all
Iterable
s are printed as JSON arrays maintaining iteration order, Map
s are printed as JSON objects with each entry representing one member; map entries are printed in iteration order with the entry key as the member's name and entry value as the value,- All other objects are converted to strings using their {code toString()}.
- Parameters:
value
- TheObject
matrix to be written- Throws:
SvetovidIOException
- if an error occurred during the operation.
-