Here you can find the source of readFile(String Path)
protected static String readFile(String Path)
//package com.java2s; /*/*from w w w . j a va 2 s . c om*/ * Copyright (c) 2015 Huawei, Inc. 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 */ import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class Main { protected static String readFile(String Path) { BufferedReader reader = null; String laststr = ""; try { FileInputStream fileInputStream = new FileInputStream(Path); InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8"); reader = new BufferedReader(inputStreamReader); String tempString = null; while ((tempString = reader.readLine()) != null) { laststr += tempString; } reader.close(); } catch (IOException e) { // TODO Auto-generated catch block } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { // TODO Auto-generated catch block } } } return laststr; } }