Class IO
java.lang.Object
java.io.IO
IO is a preview API of the Java platform.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A collection of static convenience methods that provide access to
system console for implicitly declared classes.
Each of this class' methods throws IOError if the system console
is null; otherwise, the effect is as if a similarly-named method
had been called on that console.
- Since:
- 23
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidWrites a string representation of the specified object to the system console and then flushes that console.static voidWrites a string representation of the specified object to the system console, terminates the line and then flushes that console.static StringWrites a prompt as if by callingprint, then reads a single line of text from the system console.
-
Method Details
-
println
Writes a string representation of the specified object to the system console, terminates the line and then flushes that console. IfSystem.console()returnsnull, throwsIOError. Otherwise, the effect is as ifprintln(obj)PREVIEW had been called onSystem.console().- Parameters:
obj- the object to print
-
print
Writes a string representation of the specified object to the system console and then flushes that console. IfSystem.console()returnsnull, throwsIOError. Otherwise, the effect is as ifprint(obj)PREVIEW had been called onSystem.console().- Parameters:
obj- the object to print
-
readln
Writes a prompt as if by callingprint, then reads a single line of text from the system console. IfSystem.console()returnsnull, throwsIOError. Otherwise, the effect is as ifreadln(prompt)PREVIEW had been called onSystem.console().- Parameters:
prompt- the prompt string- Returns:
- a string containing the line read from the system console, not
including any line-termination characters. Returns
nullif an end of stream has been reached without having read any characters.
-
IOwhen preview features are enabled.