Here you can find the source of getResourceAsString(String name)
public static String getResourceAsString(String name)
//package com.java2s; //License from project: Open Source License import java.io.InputStream; import java.util.Scanner; public class Main { public static String getResourceAsString(String name) { InputStream is = getResource(name); Scanner scanner = new Scanner(is, "UTF-8"); StringBuilder sb = new StringBuilder(); while (scanner.hasNext()) { sb.append(scanner.nextLine()).append("\n"); }//from ww w . j a v a2 s .c o m return sb.toString(); } public static InputStream getResource(String name) { return Class.class.getResourceAsStream("/" + name); } }