As shown below:
import java.io.*; /** * Created by liuyikai on 2016/8/13. */public class FileUtil { public static String LoadContentByPath(String path) throws IOException { InputStream is = new FileInputStream(path); BufferedReader in = new BufferedReader(new InputStreamReader(is)); StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = in.readLine()) != null){ buffer.append(line); } return buffer.toString(); } }The above method of reading the text file with a specified path and returning String in Java is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.