public class Main {
public static void main(String[] args) throws IOException {
ConsoleReader console= new ConsoleReader();
console.setPrompt("Enter command>");
String input= console.readLine();
if(input.equals("start")){
while(true){
// Get me out of here!
}
} else{
// Do something else
}
}
}
--
You received this message because you are subscribed to the Google Groups "jline-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jline-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to jline-users...@googlegroups.com.
public class Main {
public static void main(String[] args) throws IOException, InterruptedException {
TerminalBuilder builder = TerminalBuilder.builder();
builder.nativeSignals(true);
builder.signalHandler(SignalHandler.SIG_IGN);
Terminal terminal = builder.build();
// Not sure what to do with this...
SignalHandler signalHandler= terminal.handle(Signal.QUIT, SignalHandler.SIG_IGN);
LineReader reader = LineReaderBuilder.builder()
.terminal(terminal)
.build();
String line = reader.readLine("Enter command>", null, null, null);
if(line.equals("start")){
System.out.println("Endless loop started...");
endless(); // Here: capture Ctrl+C to stop endless()
} else{
System.out.println("bye");
System.exit(0);
}
}
private static void endless() throws InterruptedException {
int i= 1;
while(true){
System.out.println("waiting " + i);
i++;
Thread.sleep(1000);
To unsubscribe from this group and stop receiving emails from it, send an email to jline-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to jline-users+unsubscribe@googlegroups.com.