Link to home
Start Free TrialLog in
Avatar of Christopher Schene
Christopher ScheneFlag for United States of America

asked on

How do I extract a number from a Java string?

I have the following string in Java:

"Send data to port 2112 with this entire message intact"

What is a good way to extract the number from the string and place "2112" in an integer?

I know some "brute force or hard" ways to do this but I am looking for something that uses good Java programming techniques.

What I am actually doing here is testing that ports are available---so i send a message to a server on port 2112 and tell it to send me back the same message on the specified port.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Christopher Schene

ASKER

Works great! Thanks!
Fast response!
Good Answer....
:)