我有applet这样的start()代码:
public void start() {
try {
URL cgiUrl = new URL("http://localhost:8080/cgi_lib/UsersCGI.exe?someText");
URLConnection con = cgiUrl.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
OutputStream out = con.getOutputStream();
DataInputStream din = new DataInputStream(con.getInputStream());
DataOutputStream dout = new DataOutputStream(out);
dout.writeUTF("Hello");
String receivedString = din.readUTF();
this.out=receivedString;
} catch (MalformedURLException e) {
e.printStackTrace();
}
catch (IOException ex){
ex.printStackTrace();
}
}
CGI用java编写并编译成.exe(使用launch4j):
public class UsersCGI {
public static void main(String[] args) {
System.out.println(Arrays.toString(args));
}
}
所以,我有错误:
" java.io.UTFDataFormatException:字节0和#34之间格式错误的输入;
在第
行String receivedString = din.readUTF();
我做错了什么?