Format Console output in Java
Description
The following code shows how to format Console output.
Example
/* w w w. ja va2 s . com*/
import java.io.Console;
import java.sql.SQLException;
public class Main {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Console console = System.console();
if (console == null) {
System.err.println("sales: unable to obtain console");
return;
}
console.printf("%s ", "string");
}
}
The code above generates the following result.