0
我有一个关于URI和URL的问题 当我通过一个url是工作好,但结果是最糟糕的需要帮助!Java,URL输出与java输出不同
因为我的代码是这样的。
import java.io.*;
import java.net.*;
import java.net.URL;
public class isms {
public static void main(String[] args) throws Exception {
try {
String user = new String ("boo");
String pass = new String ("boo");
String dstno = new String("60164038811"); //You are going compose a message to this destination number.
String msg = new String("你的哈达哈达!"); //Your message over here
int type = 2; //for unicode change to 2, normal will the 1.
String sendid = new String("isms"); //Malaysia does not support sender id yet.
// Send data
URI myUrl = new URI("http://www.isms.com.my/isms_send.php?un=" + user + "&pwd=" + pass
+ "&dstno=" + dstno + "&msg=" + msg + "&type=" + type + "&sendid=" + sendid);
URL url = new URL(myUrl.toASCIIString());
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
// Print the response output...
System.out.println(line);
}
rd.close();
System.out.println(url);
} catch (Exception e) {
e.printStackTrace();
}
}
}
在网络的输出是不同的.. 在我的Java输出
你的哈达哈达!
,但在我的网站是
ÄãμĹþ'ï¹þ'ï!
帮助!!
你能提供更多关于你在网站上打印这些东西的详细信息吗? – raygozag
编码是你的问题,你必须使用另一种编码,接受亚洲字母..顺便说一句,不要使用'新的字符串'而是使用只是“”和psw不应该传入'GET METHOD' – nachokk
@raygozag该网站是一个消息服务,当你改变它将发送到目的地号码的消息。 –