Here you can find the source of getFileResourceText(String path)
Parameter | Description |
---|---|
path | the resource's file path |
Parameter | Description |
---|
public static String getFileResourceText(String path) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Main { private static final String NEW_LINE = "\n"; /**//from www . j a v a 2 s .com * Gets the text from the URL resource. * <p/> * * @param path the resource's file path * @return the resource's text * @throws java.io.IOException if the resource was not found */ public static String getFileResourceText(String path) throws IOException { BufferedReader fileReader = null; StringBuilder stringBuilder = new StringBuilder(); try { fileReader = new BufferedReader(new FileReader(path)); String line = null; while ((line = fileReader.readLine()) != null) { stringBuilder.append(line); stringBuilder.append(NEW_LINE); } } finally { if (fileReader != null) { fileReader.close(); } } return stringBuilder.toString(); } }