gpt4 book ai didi

Java 创建长字符串

转载 作者:行者123 更新时间:2023-11-30 02:57:31 25 4
gpt4 key购买 nike

我有一个小问题,无法自己解决。检查这段代码:

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();

它只是创建并向服务器发送请求。如果 cmd 足够短,一切正常。调试器打印(顺便说一句,这是安卓应用程序) enter image description here

除此之外,一切正常。但是如果我向这个函数传递更长的东西,我会得到异常 java EOFexception

看起来是这样的。我不知道,看起来这个字符串分成两个字符串?我应该怎么做才能解决这个问题?谢谢你花时间.. enter image description here

最佳答案

我的理论是您的 base 64 编码正在插入新行。服务器只收到一行并感到不安,因为它代表了 base64 数据的 fragment 。

因此要禁用此功能,请使用 NO_WRAP 而不是 DEFAULT。

关于Java 创建长字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23036090/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com