my dog learned polymorphism*
The moose likes Beginning Java and the fly likes Split() String Tokenizer question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Split() String Tokenizer question" Watch "Split() String Tokenizer question" New topic
Author

Split() String Tokenizer question

Ray Zeigler
Greenhorn

Joined: Jul 06, 2012
Posts: 18
im trying to have my server report back a string that tells the client how many integers and non-integer words were in the previous message.
)For example I send the following message from my client to my server "Hi today is July 6"
I want my server to return a string "4 1"
Indicating that the incoming string has 4 non integer words and 1 integer.

Can someone show me the code of how to do this?
I know I can use Split() or String Tokenizer but I cant figure out how to do it

This is my code
M Massa
Greenhorn

Joined: Sep 03, 2010
Posts: 7
Ray Zeigler
Greenhorn

Joined: Jul 06, 2012
Posts: 18
Say for instance I wanted it to do this count not from a phrase as you showed previously but instead from the data received in the server from the client. How would the code look for something like that?

String Str= new String(receivePacket.getData());
System.out.println("The received string was: " + Str);
System.out.println("It contains: " + numInts
+ " num of Integers and " + numNonInts + " number of Non Integers");





Ray Zeigler
Greenhorn

Joined: Jul 06, 2012
Posts: 18
=) Sorry for my silly previous reply.. it was much easier than I thought.
This is what I came up with.. Does it appear proper to you?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Split() String Tokenizer question
 
Similar Threads
Pinger time!
java udp socket programming problem
Problem regarding socket time out exception.
Simple problem in running a Server class
Responses from UDP Server