i need to pass a string of arabic value to the HttpURL as a parameter but before i do say when i print the message its showing only question marks
public void sendSms(SendSms object) throws MalformedURLException,ProtocolException,IOException {
String message=new String(object.getMessage().getBytes(), "UTF-8");
System.out.println(message);//printing only question marks
}
and even when i send the message as url parameter its not sending the original message as arabic its sending the question marks.
public void sendSms(SendSms object) throws MalformedURLException, ProtocolException,IOException {
String message=new String(object.getMessage().getBytes(), "UTF-8");
System.out.println(message);
PrintStream out = new PrintStream(System.out, true, "UTF-8");
out.print(message);
String charset="UTF-8";
URL url = new URL("http://62.215.226.164/fccsms_P.aspx");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestProperty("Accept-Charset", charset);
con.setRequestMethod("POST");
//con.setRequestProperty("User-Agent", USER_AGENT);
con.setRequestProperty("Accept-Language", "en-US,en,ar_KW;q=0.5");
con.setRequestProperty("Content-Type", "text/html;charset=utf-8");
String urlParameters = "UID=test&P=test&S=InfoText&G=965"+object.getPhone()+"&M= Hello "+object.getName()+" "+message+" &L=A";
// Send post request
con.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(con.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
int responseCode = con.getResponseCode();
System.out.println("\nSending 'POST' request to URL : " + url);
System.out.println("Post parameters : " + urlParameters);
System.out.println("Response Code : " + responseCode);
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
}