| 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";
|
 |
 |
|
|
subject: Console Input to UDP DatagramPacket?
|
|
|