1 | public static String loadTextFileWithEncoding(String fileName, S encoding) {
|
2 | return loadTextFileWithEncoding(fileName, null, encoding); |
3 | } |
4 | |
5 | public static String loadTextFileWithEncoding(String fileName, String defaultContents, S encoding) {
|
6 | try {
|
7 | if (!new File(fileName).exists()) |
8 | return defaultContents; |
9 | |
10 | FileInputStream fileInputStream = new FileInputStream(fileName); |
11 | InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, encoding); |
12 | return loadTextFile(inputStreamReader); |
13 | } catch (IOException e) {
|
14 | throw new RuntimeException(e); |
15 | } |
16 | } |
17 | |
18 | public static String loadTextFileWithEncoding(File f, String defaultContents, S encoding) {
|
19 | ret f == null ? defaultContents : loadTextFileWithEncoding(f.getPath(), defaultContents, encoding); |
20 | } |
21 | |
22 | public static String loadTextFileWithEncoding(File fileName, S encoding) {
|
23 | return loadTextFileWithEncoding(fileName, null, encoding); |
24 | } |
Began life as a copy of #1001049
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1009008 |
| Snippet name: | loadTextFileWithEncoding |
| Eternal ID of this version: | #1009008/4 |
| Text MD5: | 0a0546ec78190157557892b34dced123 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-06-26 17:50:43 |
| Source code size: | 961 bytes / 24 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 700 / 715 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |