Here you can find the source of printDocument(File file)
public static String printDocument(File file) throws IOException, TransformerException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import javax.xml.transform.TransformerException; public class Main { public static String printDocument(File file) throws IOException, TransformerException { BufferedReader br = new BufferedReader(new FileReader(file)); String line = null, fileContent = ""; while ((line = br.readLine()) != null) { fileContent += line + "--"; }/* www . ja va 2 s .c o m*/ return fileContent; } }