Package com.tnsai.utils
Class Spinner
java.lang.Object
com.tnsai.utils.Spinner
- All Implemented Interfaces:
AutoCloseable
Terminal spinner for showing loading state.
Example:
Spinner spinner = new Spinner("Thinking");
spinner.start();
// Do some work
spinner.stop();
Or using try-with-resources:
try (Spinner spinner = new Spinner("Processing")) {
// Do some work
}
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a spinner with the given message.Creates a spinner with custom configuration.Spinner(String message, String[] bulletChars, boolean showInterruptHint, PrintStream output) Creates a spinner with custom output stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()AutoCloseable implementation for try-with-resources.static voidExample usage.voidstart()Starts the spinner animation.voidstop()Stops the spinner animation.voidupdateMessage(String newMessage) Updates the spinner message while it's running.
-
Constructor Details
-
Spinner
Creates a spinner with the given message. -
Spinner
Creates a spinner with custom configuration.- Parameters:
message- Message to display next to spinnerbulletChars- Custom bullet animation characters (null for default)showInterruptHint- Show "(esc to interrupt)" hint
-
Spinner
Creates a spinner with custom output stream.
-
-
Method Details
-
start
public void start()Starts the spinner animation. -
stop
public void stop()Stops the spinner animation. -
updateMessage
Updates the spinner message while it's running. -
close
public void close()AutoCloseable implementation for try-with-resources.- Specified by:
closein interfaceAutoCloseable
-
main
Example usage.
-