Libraryless. Click here for Pure Java version (2523L/16K).
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); }
Began life as a copy of #2000322
download show line numbers debug dex old transpilations
Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv
No comments. add comment