static S loadTextFile(S fileName) { return loadTextFile(fileName, null); } static S loadTextFile(File f, S defaultContents, S encoding default "UTF-8") ctex { ifndef LeanMode checkFileNotTooBigToRead(f); endifndef if (f == null || !f.exists()) ret defaultContents; FileInputStream fileInputStream = new FileInputStream(f); InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, encoding); ret loadTextFile(inputStreamReader); } public static String loadTextFile(File fileName) { return loadTextFile(fileName, null); } static S loadTextFile(S fileName, String defaultContents) { ret fileName == null ? defaultContents : loadTextFile(newFile(fileName), defaultContents); } static S loadTextFile(Reader reader) throws IOException { new StringBuilder builder; try { char[] buffer = new char[1024]; int n; while (-1 != (n = reader.read(buffer))) builder.append(buffer, 0, n); } finally { reader.close(); } ret str(builder); }