Here you can find the source of readFile(String path)
Parameter | Description |
---|---|
path | The directory or path to the text file |
public static String readFile(String path)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Main { /**//w w w .j a va 2s.c o m * * Reads file and stores into a string and returns it in one method * * @see BufferedReader * * @param path The directory or path to the text file * @return str */ public static String readFile(String path) { String str = ""; try { BufferedReader reader = new BufferedReader(new FileReader("path")); String tmp = ""; while ((tmp = reader.readLine()) != null) str += ""; reader.close(); } catch (IOException e) { e.printStackTrace(); } return str; } }