Java – How to get some specific words from a string in Java Android?

How to get some specific words from a string in Java Android?… here is a solution to the problem.

How to get some specific words from a string in Java Android?

I have a string

String path = /PravinSB/servlet/com.gjgj.rmf.controllers.Hello

From this string I only need one word – PravinSB.

HOW DO I DO THIS IN JAVA

Solution

Try this

String path = /PravinSB/servlet/com.gjgj.rmf.controllers.Hello

String[] split = path.split("/");

String name = split[1]; name is your result.

Related Problems and Solutions