如何解决xml文件中显示中文的问题.
我从一个xml文件中读取数据,将其显示在页面上,但是只要xml中有中文,就显示不出来.我的代码如下:
try {
url = new URL(path);
urlcon = url.openConnection();
read = urlcon.getInputStream();
buf = new BufferedReader(new InputStreamReader(read));
out = response.getOutputStream();
line = StringUtil.repNull(buf.readLine());
//show xml file
while (!"".equals(line)) {
contents = contents + line;
line = StringUtil.repNull(buf.readLine());
}
out.write(contents.getBytes());
out.flush();
out.close();
} catch (Exception e) {
return e.getMessage();
}