Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Console Input to UDP DatagramPacket?

Alan Blair
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to this. I need to use the input from the console to make some programming decisions. Next I want to append some values to this console input. Finally, I want to turn it into a bytestream and make it part of the SendData in a UDP DatagramPacket.
Below is my code to tokenize the console input. It compiles, but hangs up when I use java to execute it. If I hit enter twice it runs. However, the tokens are not displayed. But it does display the bytes.
question 1. How do I prevent the hangup when
I execute the program?
question 2. Why will not the tokens display?
question 3. How do I append constants to the console input and then send via a Datagram Packet (e.g., use .getBytes).
try {

InputLine = inFromUser.readLine();
if (InputLine==null) return;

str = new StringTokenizer(InputLine);
text = str.nextToken();
destination = str.nextToken();
bitrateStr = str.nextToken();
//Convert bitrate into a float object and then convert float object into a Float data type
bitrate = (Float.valueOf(bitrateStr)).floatValue();
sentence2 = inFromUser.readLine();
sentence2 = sentence2 + "0";
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic