Create a Console Screen Buffer using Java

Viewed 99

I would like to use the console as a "screen" in order to display a game of tic-tac-toe without printing a new board below the previous one at each turn.

I have seen some examples of how to do this in C++ on Windows using the CreateConsoleScreenBuffer function.

Any way to do this with Java (on a mac)?

1 Answers

One thing I used for this in my early java days was printing a large number of return characters:
Ex. for(int i = 0; i < 30; i++){System.out.println("\n");} to make the previous board "disappear".

From what I have seen there's no easy way to clear the console screen like c++ does because of the limitations between java and the console.

if you want something a little different I'd recommend learning how to work with and use GUIs and I believe you'd be able to move a substantial amount of your code over and have it work mostly the same.

Related