Hi,
I have a problem to use URLConnection and URLEncoder
Here is my code:
String _url = http://192.168.6.1/Controller?msg=test";
URL url = new URL(_url);
URLConnection uc = url.openConnection();
uc.connect();
String source = "";
BufferedReader reader;
StringBuffer strbuf = new StringBuffer();
String line;
try {
reader = new BufferedReader(new InputStreamReader(url.openStream()));
while ((line = reader.readLine()) != null)
strbuf.append(line + "\n");
reader.close();
source = strbuf.toString();
System.out.println("output :"+source);
}catch(Exception e) {
e.printStackTrace();
System.out.println("Unable to establish connection to " + url);
}
Well, if the url like this is fine, but if my _url string is contain space
or others special character then it failed.
I also try like this
URL url = new URL(URLEncoder.encode(_url));
but it also failed.
Anyone know how to solve my problem?
Thanks
Regards,
Louis
ø¤°`°¤ø,¸¸¸,ø¤°`°¤ø,¸¸»«¸,ø¤°`°¤ø,¸¸,ø¤°`°¤ø