Here you can find the source of readFile(String filename)
public static String readFile(String filename) throws IOException
//package com.java2s; /*/*from www . j a v a2 s . c o m*/ werecloud provides a simple API to the VMWare vCenter data. Copyright (C) 2015 NigelB This program 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 2 of the License, or (at your option) any later version. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import java.io.*; public class Main { private static final int BLOCK_SIZE = 1024; public static String readFile(String filename) throws IOException { File d = new File(filename); FileInputStream fin = new FileInputStream(d); byte b[] = readStream(fin); fin.close(); return new String(b); } public static byte[] readStream(InputStream is) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(BLOCK_SIZE); byte[] buffer = new byte[BLOCK_SIZE]; int len = is.read(buffer); while (len > 0) { bos.write(buffer, 0, len); len = is.read(buffer); } return bos.toByteArray(); } }