字符串转换为输入流:
String text = "<?xml version=\"1.0\" encoding=\"gb2312\"?><students><student sn=\"22\"><name>张三</name>" +
"<age>18</age></student></students>";
InputStream inputStream = new ByteArrayInputStream(text.getBytes("UTF-8"));
输入流转为字符串:
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("D:\\qinshipeng\\dom4j\\student.xml")));