Top Description Constructors Methods
java.io

public final Class IO

extends Object
Class Inheritance
Annotations
@PreviewFeature
feature:IMPLICIT_CLASSES
Imports
jdk.internal.javac.PreviewFeature

Preview

Third Preview of Implicitly Declared Classes and Instance Main Methods (JEP 477).

Programs can only use IO when preview features are enabled.
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.

Input and output from methods in this class use the character set of the system console as specified by Console#charset.

Since
23

Constructor Summary

AccessConstructor and Description
private
IO()

Method Summary

Modifier and TypeMethod and Description
private static Console
con()

public static void
println(Object
the object to print, may be null
obj
)

Writes a string representation of the specified object to the system console, terminates the line and then flushes that console.

public static String

Returns:

a string containing the line read from the system console, not including any line-termination characters. Returns null if an end of stream has been reached without having read any characters.
readln
(String
the prompt string, may be null
prompt
)

Writes a prompt as if by calling print, then reads a single line of text from the system console.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

IOback to summary
private IO()

Method Detail

conback to summary
private static Console con()
printlnback to summary
public static void println(Object obj)

Writes a string representation of the specified object to the system console, terminates the line and then flushes that console.

The effect is as if println(obj) had been called on System.console().

Parameters
obj:Object

the object to print, may be null

Exceptions
IOError:
if System.console() returns null, or if an I/O error occurs
readlnback to summary
public static String readln(String prompt)

Writes a prompt as if by calling print, then reads a single line of text from the system console.

The effect is as if readln(prompt) had been called on System.console().

Parameters
prompt:String

the prompt string, may be null

Returns:String

a string containing the line read from the system console, not including any line-termination characters. Returns null if an end of stream has been reached without having read any characters.

Exceptions
IOError:
if System.console() returns null, or if an I/O error occurs