Here you can find the source of readFile(String resource)
public static String readFile(String resource) throws IOException
//package com.java2s; /*//from w w w . j av a 2s. co m Chromis POS - The New Face of Open Source POS Copyright (c) 2015 (John Lewis) Chromis.co.uk http://www.chromis.co.uk kitchen Screen v1.5 This file is part of chromis & its associated programs chromis is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. chromis is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with chromis. If not, see <http://www.gnu.org/licenses/>. */ import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class Main { public static String readFile(String resource) throws IOException { FileInputStream in = new FileInputStream(resource); if (in == null) { throw new FileNotFoundException(resource); } ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len; while ((len = in.read(buffer)) > 0) { out.write(buffer, 0, len); } byte[] data = out.toByteArray(); return new String(data, "UTF-8"); } }