Here you can find the source of getFileContents(File testFile)
public static String getFileContents(File testFile)
//package com.java2s; /******************************************************************************* * Copyright (c) 2011, 2015 EclipseSource and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w. ja va2 s. c o m * EclipseSource - initial API and implementation ******************************************************************************/ import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static String getFileContents(File testFile) { // TODO [rst] Buffer can get very big with the wrong file byte[] buffer = new byte[(int) testFile.length()]; try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(testFile))) { bis.read(buffer); return new String(buffer); } catch (IOException exception) { throw new RuntimeException(exception); } } }