/** * Loads a given remote text file. * * @param textFileURL * The given text file URL. * @return The content of the text file. * @throws IOException * If any I/O exception occurs. */ public static String loadTextFile(URL textFileURL) throws IOException { URLConnection urlConnection = textFileURL.openConnection(); // See https://issues.apache.org/jira/browse/UIMA-1746 urlConnection.setUseCaches(false); return loadTextFile(urlConnection); }
private static String getText(File each) { try { return org.apache.uima.pear.util.FileUtil.loadTextFile(each, "UTF-8"); } catch (IOException e) { DLTKCore.error(e.getMessage(), e); } return ""; }
/** * Loads a given local text file using the default file encoding. * * @return The content of the text file. * @param textFile * The given text file. * @throws IOException * If any I/O exception occurs. */ public static String loadTextFile(File textFile) throws IOException { BufferedReader iStream = null; String content = null; try { iStream = new BufferedReader(new FileReader(textFile)); content = loadTextFile(iStream); } catch (IOException exc) { throw exc; } finally { if (iStream != null) { try { iStream.close(); } catch (Exception e) { } } } return content; }
try { iStream = new BufferedReader(new InputStreamReader(jarFile.getInputStream(jarEntry))); content = loadTextFile(iStream); } finally { if (iStream != null) {
/** * Loads a given remote text file. * * @param urlConnection * The given URL connection. * @return The content of the text file. * @throws IOException * If any I/O exception occurs. */ public static String loadTextFile(URLConnection urlConnection) throws IOException { BufferedReader iStream = null; String content = null; // See https://issues.apache.org/jira/browse/UIMA-1746 urlConnection.setUseCaches(false); try { iStream = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); content = loadTextFile(iStream); } catch (IOException exc) { throw exc; } finally { if (iStream != null) { try { iStream.close(); } catch (Exception e) { } } } return content; }
/** * Loads a given local text file using a specified file encoding. * * @return The content of the text file. * @param textFile * The given text file. * @param encoding * The given text file encoding name. * @throws IOException * If any I/O exception occurs. */ public static String loadTextFile(File textFile, String encoding) throws IOException { BufferedReader iStream = null; String content = null; try { iStream = new BufferedReader(new InputStreamReader(new FileInputStream(textFile), encoding)); content = loadTextFile(iStream); } catch (IOException exc) { throw exc; } finally { if (iStream != null) { try { iStream.close(); } catch (Exception e) { } } } return content; }
String fileContent = loadTextFile(textFile, encoding); BufferedReader sReader = null; PrintStream fStream = null;