如果现在有test.xml public class test {
public static void main(String args[]){
String path="test.xml";
StringBuffer contentBuffer =new StringBuffer("");
StringBuffer result=new StringBuffer("");
String line=null;
BufferedReader inputStream;
try {
inputStream = new BufferedReader(new FileReader(txtFilename));
line = inputStream.readLine();
while (line!=null){
result.append(line+'\n');
line = inputStream.readLine();
}
System.out.print(fileContent);
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
但是如果test.xml中有中文的话 ,结果打印出来的就会乱码。怎样才不会乱码啊??????????就是说test.xml中有 <tp>数据提取 </tp>,那么打印出来的也是 <tp>数据提取 </tp>
各位高手快来帮我呀!万分感谢!!!!!!
public static void main(String args[]){
String path="test.xml";
StringBuffer contentBuffer =new StringBuffer("");
StringBuffer result=new StringBuffer("");
String line=null;
BufferedReader inputStream;
try {
inputStream = new BufferedReader(new FileReader(txtFilename));
line = inputStream.readLine();
while (line!=null){
result.append(line+'\n');
line = inputStream.readLine();
}
System.out.print(fileContent);
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
但是如果test.xml中有中文的话 ,结果打印出来的就会乱码。怎样才不会乱码啊??????????就是说test.xml中有 <tp>数据提取 </tp>,那么打印出来的也是 <tp>数据提取 </tp>
各位高手快来帮我呀!万分感谢!!!!!!
public class Test1 {
public static void show()
{
String path="c://test.txt";
StringBuffer result=new StringBuffer("");
String line="";
BufferedReader br=null;
try
{
br = new BufferedReader(new FileReader(path));
line = br.readLine();
while (line!=null)
{
result.append(line+'\n');
System.out.print(result);
line = br.readLine();
}
}
catch (Exception e)
{ e.printStackTrace();
}
}
public static void main(String[] args)
{
show();
}
你试试,我运行过了,是正确得……
二楼的,那要怎样设置才行啊????????
我的xml的头部是:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Created from PDF via Acrobat SaveAsXML -->
<!-- Mapping Table version: 28-February-2003 -->