Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.FileReader; public class Main { public static String getXMLString(String filePath) { StringBuffer sb = new StringBuffer(); BufferedReader br = null; String line; try { br = new BufferedReader(new FileReader(filePath)); while (true) { line = br.readLine(); if (line == null) { break; } sb.append(line + "\n"); } } catch (Exception e) { e.printStackTrace(); } return sb.toString(); } }