在JAVA如何将ASCII码转为utf输出到一个文本文档中?
    各位大神,情况是这样的,领导交代我一直在爬网,现在已经爬到了回复处,在各位大神的帮助下,小弟已经找到了回复的源码,不过源码却是ASCII格式的,请问如何将其转换为utf格式,方便存入文本文档中。源码如下:

这是一个回复内容数据:

 \u975e\u5e38\u4e0d\u9519\u7684\u4e00\u7bc7\u6587\u7ae0\uff0c\u5e72\u8d27\uff0c\u5e72\u8d27\u3002\u628a\u793e\u4ea4\u8fd0\u8425\u8bb2\u7684\u900f\u5f7b\u3002

这个全部回复JS的相应数据:

 {"errno":0,"data":{"hasmore":true,"comments":[{"user_name":"Fei52012345","user_pic":"http:\/\/tb.himg.baidu.com\/sys\/portraitn\/item\/e8474665693532303132333435da38","user_type":"0","ts":"1431394929000","id":"507196","text":"\u975e\u5e38\u4e0d\u9519\u7684\u4e00\u7bc7\u6587\u7ae0\uff0c\u5e72\u8d27\uff0c\u5e72\u8d27\u3002\u628a\u793e\u4ea4\u8fd0\u8425\u8bb2\u7684\u900f\u5f7b\u3002","from":"weibo","support_count":"1","vip_intro":"","format_ts":"23\u5206\u949f\u524d"},{"user_name":"\u5584\u826f\u7684\u5e73\u6c11","user_pic":"http:\/\/tb.himg.baidu.com\/sys\/portraitn\/item\/21e0c9c6c1bcb5c4c6bdc3f11228","user_type":"0","ts":"1431394912000","id":"507198","text":"\u6709\u601d\u60f3\uff01\u900f\u8fc7\u73b0\u8c61\u770b\u5230\u672c\u8d28\uff01\u73b0\u5728\u7684\u98ce\u6c14\u5c31\u662f\u592a\u6d6e\u4e86\uff0c\u8ba4\u4e3a\u81ea\u5df1\u53ef\u4ee5\u4f5c\u4efb\u4f55\u4e8b\uff0c\u4efb\u4f55\u90fd\u53ef\u80fd\u6210\u529f\uff0c\u5728\u9047\u5230\u95ee\u9898\u4e4b\u524d\u5c31\u8ba4\u4e3a\u81ea\u5df1\u7684\u60f3\u6cd5\u548c\u4f5c\u6cd5\u662f\u771f\u7406\uff01","from":"weibo","support_count":"0","vip_intro":"","format_ts":"23\u5206\u949f\u524d"}],"ts":"1431327560000"}}

2个回答

这是 json 格式的数据啊。用 org.json 包就行了。会自动转义的。

使用gson.jar包就行了,会自动帮你转的~

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐