Luís Tavares Luís Tavares - 1 year ago 54
HTTP Question

How to copy URL character values into string

I'm trying to store a value of a GET request into another variable.
When I try to do that with numbers, such a:

I store the values using the next method:

int valor1 = Integer.parseInt(streamAux.substring(pos1+2, pos2-1).trim());

int valor2 =Integer.parseInt(streamAux.substring(pos2+2, pos3-1).trim());

However, I want to do that with characters.

How do I do that? I tried establishing a string and giving it the same output like this:

String testx = "";
testx = streamAux.substring(pos11+22, pos22-11);

However, it does not work.

The streamAux object is a string which holds the GET request.
pos11 and pos22 come from this:

int pos11=streamAux.indexOf("=R");
int pos22=streamAux.indexOf(",");
int pos33=streamAux.indexOf("HTTP/1.1");

Can somebody give me a help?

Answer Source

Here it is. Try it.

string a=streamAux.subString(i,j);
int b=Integer.parseInt(streamAux.subString(i))

a is received as string keeping 'RS' in it. b is integer. Hope it is what you want.

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