Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

java 代码 字符串处理 疑惑求解

 public static final void addField(String str, boolean z, String str2, boolean z2) throws IOException {
        if (str == null) {
            throw new NullPointerException("name");
        } else if (str2 != null) {
            if (content.size() > 0) {
                content.write(38);
            }
            String str3 = "UTF-8";
            if (z) {
                try {
                    str = URLEncoder.encode(str, str3);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            if (z2) {
                str2 = URLEncoder.encode(str2, str3);
            }
            content.write(str.getBytes(str3));
            content.write(61);
            content.write(str2.getBytes(str3));
        } else {
            throw new NullPointerException("value");
        }
    }

这个代码里面的 content.write(61); 我打印了结果 和我穿进去的字符串结果是一样的,请问这里的61有什么用呢?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

代码是反编译的吧? ascii 38 是 &字符,61是 =,这就是在拼URL参数而已。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...