extracting of string parameter value from java output -


this question has answer here:

hi getting following output java code:

access_token=caaw2msimwaqbajslgf1yfu3rjzizzcfkb3zai9uazctwou52s9eeuxxnyv0nbdzapnphwwhgcdp9icvei7qlixrcc43ierm5oqbedplk3fzclpzbeawry2njkm4o3e4llciiujplddnophnoxczj9fmb2czcaqilbh2cdnid1i4qzbkkgwgtluikcz6ptt8zcl4wifagtfl5o6fgnbibgm89f&expires=5181699 

how retrieve value of access_token? code below:

 string line;         stringbuffer buffer = new stringbuffer();         bufferedreader reader = new bufferedreader(new inputstreamreader(                 conn.getinputstream()));          while ((line = reader.readline()) != null)          {             buffer.append(line);         }          reader.close();         conn.disconnect();        string response1= buffer.tostring(); 

thank you.

you can using split() method of string

try this.

string [] response = response1.split("&");  system.out.println("my token : " + response[0]); 

the output be

access_token=caaw2msimwaqbajslgf1yfu3rjzizzcfkb3zai9uazctwou52s9eeuxxnyv0nbdzapnphwwhgcdp9icvei7qlixrcc43ierm5oqbedplk3fzclpzbeawry2njkm4o3e4llciiujplddnophnoxczj9fmb2czcaqilbh2cdnid1i4qzbkkgwgtluikcz6ptt8zcl4wifagtfl5o6fgnbibgm89f 

then value of access_token try this,

  string [] tokenvalue = response[0].split("=");    system.out.println("my token value : " + tokenvalue[1]); 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -