1 | static Lock appendToFile_lock = lock(); |
2 | sbool appendToFile_keepOpen; |
3 | static new HashMap<S, Writer> appendToFile_writers; |
4 | |
5 | static void appendToFile(S path, S s) ctex { |
6 | lock appendToFile_lock; // Let's just generally synchronize this to be safe. |
7 | mkdirsForFile(new File(path)); |
8 | path = getCanonicalPath(path); |
9 | Writer writer = appendToFile_writers.get(path); |
10 | if (writer == null) { |
11 | //print("[Logging to " + path + "]"); |
12 | writer = new BufferedWriter(new OutputStreamWriter( |
13 | newFileOutputStream(path, true), "UTF-8")); |
14 | if (appendToFile_keepOpen) |
15 | appendToFile_writers.put(path, writer); |
16 | } |
17 | writer.write(s); |
18 | if (!appendToFile_keepOpen) |
19 | writer.close(); |
20 | } |
21 | |
22 | static void appendToFile(File path, String s) { |
23 | if (path != null) |
24 | appendToFile(path.getPath(), s); |
25 | } |
26 | |
27 | svoid cleanMeUp_appendToFile { |
28 | temp tempCleaningUp(); |
29 | lock appendToFile_lock; |
30 | closeAllWriters(values(appendToFile_writers)); |
31 | appendToFile_writers.clear(); |
32 | } |
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001067 |
Snippet name: | appendToFile |
Eternal ID of this version: | #1001067/9 |
Text MD5: | 5d5ef0e1745eacaa9e13a6ba191eceb5 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-12-02 16:51:24 |
Source code size: | 992 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 810 / 2512 |
Version history: | 8 change(s) |
Referenced in: | [show references] |