展开全部
检查一下对方url的编码
在获取时指定一下字符编码就行了URL url = new URL(path);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//这里需要去查看一下url编码
//conn.setRequestProperty("contentType", "GBK");
conn.setRequestProperty("contentType", "UTF-8");
然后取出来32313133353236313431303231363533e58685e5aeb931333337613764的数据就不会是????了
想要输出到文本里我给你一个方法/**
* 追加文件:使用FileWriter
*
* @param fileName
* @param content
*/
public static void contentAppend(String fileName, String content) {
FileWriter writer = null;
try {
// 打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
writer = new FileWriter(fileName, true);
writer.write(content);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if(writer != null){
writer.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}