user2093576 user2093576 -4 years ago 78
Java Question

How do I split string between From text.charAt() till space occurs in java?

How do I split string between From text.charAt(9) till next space occurs in java?

jhb 9jb 38888 hjbhjb7868hgvhv

I need to extact 38888

Answer Source

You can use substring method twice.

  • First, get substring from 9th character (till the end of the String)

  • Get another substring from 0 to index of the first whitespace, for the String retrieved in above step

String s = "jhb 9jb 38888 hjbhjb7868hgvhv"; String subString = s.substring(8); System.out.println(subString.substring(0, subString.indexOf(" ")));

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download