1

I get a Json format data in android and I combine them and store in String like that. Now I want only particular strings.

$String outPut = "Doc Name: "+name + "\nRoom No: " + number+ "\nTime:"+time;
Doc Name: John 
Room No: 12 
Time: 09:00:00

I want to get only "John" and "12" and "09:00:00".

3
  • String time = jsonobject.getString("Time"); Commented Oct 23, 2013 at 13:33
  • @SURESH ATTS how i use Json praser i have store the date in list as and now i want to get only the name time and room no to send to next activity. Commented Oct 23, 2013 at 13:54
  • @ArshadParwez could you kindly explain little bit more so that i get the exact idea. Commented Oct 23, 2013 at 13:55

1 Answer 1

3
String[] parts = outPut.split(":");
System.out.println(parts[1]);//prints John
System.out.println(parts[3]);//prints 12
System.out.println(parts[5]+":"+parts[6]+":"+parts[7]);//prints 09:00:00
Sign up to request clarification or add additional context in comments.

1 Comment

i have printed only parts[1] but it show an error java.lang.ArrayIndexoutofbounf

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.