Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Main { /** * Read content of file on disk * * @param filename The absolute filename * @return */ static public String readAll(String filename) { try { FileReader fileReader = new FileReader(filename); BufferedReader bufferedReader = new BufferedReader(fileReader); StringBuilder stringBuilder = new StringBuilder(); String currentLine; while ((currentLine = bufferedReader.readLine()) != null) stringBuilder.append(currentLine + "\n"); return stringBuilder.toString(); } catch (IOException e) { e.printStackTrace(); } return ""; } }