I have a little problem and cant solve it myself. Check this little piece of code:
private void setCommand(String cmd, String uid) {
String b64cmd = new String(Base64.encode(cmd.getBytes(), Base64.DEFAULT));
try {
StringBuilder bulitString = new StringBuilder("http://adwi.net84.net/zserver.php?r=setcmd&pwd=123&uid=");
bulitString.append(uid);
bulitString.append("&cmd=");
bulitString.append(b64cmd);
URL url = new URL(bulitString.toString());
System.out.println(bulitString.toString());
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.getInputStream();
It just creates and sends request to the server. Everything works fine if the cmd is short enaugh. Debugger prints (this is android app btw)
And everything works fine, as excepted. But if I pass something longer to this function I get exception java EOFexception
it looks like that. I dont know, it looks like this string breaks into two strings? What should I do to fix this? Thanks for spending your time..
My theory is your base 64 encoding is inserting new lines. The server only receives one line and gets upset because it represents a fragment of base64 data.
So to disable this use NO_WRAP rather than DEFAULT.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.