Java tutorial
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; public class Main { /** * Reads a file relative to the dir this app was started from. * @param filename relative filename to load * @return entire file as a String * @throws FileNotFoundException if file not found! */ public static String readFile(String filename) throws FileNotFoundException { String startDir = System.getProperty("user.dir"); File propertyFile = new File(startDir, filename); Scanner scan = new Scanner(new FileInputStream(propertyFile)); scan.useDelimiter("\\Z"); String content = scan.next(); scan.close(); return content; } }