Java tutorial
//package com.java2s; import java.io.*; public class Main { /** * This method reads an XML file and returns its contents as String. * @param xmlFileName The name (path) of the XML file. * @return The string (XML) representation of the XML file. * @throws Exception If there is a problem. */ public static String convertXmlToString(String xmlFileName) throws Exception { File file = new File(xmlFileName); FileInputStream insr = new FileInputStream(file); byte[] fileBuffer = new byte[(int) file.length()]; insr.read(fileBuffer); insr.close(); return new String(fileBuffer); } }