S
serge
Hi everyone,
I have been trying to read a string of characters from the keyboard but I
keep getting an IOException. I am attaching the code. Any help would be very
appreciated thanks.
/*
This class is to be used as new readline method
*/
import java.io.*;
class ReadInput
{
public static void main(String[] args)
{
InputStreamReader reader = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(reader);
ReadInput r = new ReadInput();
try{
r.readline(in);
}
catch (IOException e)
{
System.out.print("\n Exception caught \n");
}
}
public void readline(BufferedReader b)throws IOException
{
String input ="";
//Buffer is empty at the moment
while(true)
{
System.out.print("Echo<");
input = b.readLine();
// else
{
if ("".equals(input))
{
System.out.println("End");
break;
}
else
{
if("OK".equals(input))
{
System.out.println("OK command received ...");
}
}
System.out.println("Echo>" + input.toUpperCase());
}
}
//in.close();
}
}
I have been trying to read a string of characters from the keyboard but I
keep getting an IOException. I am attaching the code. Any help would be very
appreciated thanks.
/*
This class is to be used as new readline method
*/
import java.io.*;
class ReadInput
{
public static void main(String[] args)
{
InputStreamReader reader = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(reader);
ReadInput r = new ReadInput();
try{
r.readline(in);
}
catch (IOException e)
{
System.out.print("\n Exception caught \n");
}
}
public void readline(BufferedReader b)throws IOException
{
String input ="";
//Buffer is empty at the moment
while(true)
{
System.out.print("Echo<");
input = b.readLine();
// else
{
if ("".equals(input))
{
System.out.println("End");
break;
}
else
{
if("OK".equals(input))
{
System.out.println("OK command received ...");
}
}
System.out.println("Echo>" + input.toUpperCase());
}
}
//in.close();
}
}