This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes Console Input to UDP DatagramPacket? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "Console Input to UDP DatagramPacket?" Watch "Console Input to UDP DatagramPacket?" New topic
Author

Console Input to UDP DatagramPacket?

Alan Blair
Greenhorn

Joined: Mar 19, 2003
Posts: 2
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;

System.out.println(InputLine);
str = new StringTokenizer(InputLine);
text = str.nextToken();
System.out.println(text);
destination = str.nextToken();
System.out.println(destination);
bitrateStr = str.nextToken();
//Convert bitrate into a float object and then convert float object into a Float data type
bitrate = (Float.valueOf(bitrateStr)).floatValue();
System.out.println(bitrate);
sentence2 = inFromUser.readLine();
sentence2 = sentence2 + "0";
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Console Input to UDP DatagramPacket?
 
Similar Threads
can DatagramSocket work in applets
need help using StringTokenizer
Communicate 2 android in 2 emulator
Pinger time!
output in a file