A
Angus
Hello
I am writing console programs and my program waits streaming in text input
from the screen. But I need a way for the user to abort - I thought Ctrl
E - but how can I know when Ctrl E has been pressed.
I am roughly doing this sort of thing:
import java.io.*;
public class blah
{
public static void main(String[] args)
{
// declaration section:
BufferedReader cin = null; // console input
String conline;
try
{
cin = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter strings to remove last character");
System.out.println("waiting... Press Ctrl E to end session");
while ((conline = cin.readLine()) != null)
{
// If Ctrl E detected abort - break out - BUT HOW???
System.out.println("processing: " + conline);
int len = conline.length();
String strRemovedot = conline.substring(0,len-1);
System.out.println(strRemovedot);
}
cin.close();
}
catch (IOException e)
{
System.err.println("IOException: " + e);
}
}
}
I am writing console programs and my program waits streaming in text input
from the screen. But I need a way for the user to abort - I thought Ctrl
E - but how can I know when Ctrl E has been pressed.
I am roughly doing this sort of thing:
import java.io.*;
public class blah
{
public static void main(String[] args)
{
// declaration section:
BufferedReader cin = null; // console input
String conline;
try
{
cin = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter strings to remove last character");
System.out.println("waiting... Press Ctrl E to end session");
while ((conline = cin.readLine()) != null)
{
// If Ctrl E detected abort - break out - BUT HOW???
System.out.println("processing: " + conline);
int len = conline.length();
String strRemovedot = conline.substring(0,len-1);
System.out.println(strRemovedot);
}
cin.close();
}
catch (IOException e)
{
System.err.println("IOException: " + e);
}
}
}