Libraryless. Click here for Pure Java version (12862L/73K).
sclass StringHead is Closeable { settable bool readMode; settable bool writeMode; gettable BufferedReader reader; gettable Writer writer; *() {} *(Reader reader) { reader(reader); } *(Writer writer) { writer(writer); } selfType reader(Reader reader) { this.reader = bufferedReader(reader); readMode(true); this; } selfType writer(Writer writer) { this.writer = writer; writeMode(true); this; } void finish {} S readLine() { S line = readLineFromReader(reader); if (line == null) close(); ret line; } void writeLine(S line) ctex { writer.write(line); writer.write('\n'); } void exchangeLine(IF0<S> getter, IVF1<S> setter) { if (writeMode()) writeLine(getter!); if (readMode()) setter.get(readLine()); } close { dispose reader; dispose writer; } replace ByteIO with StringIO. void exchange(ByteIO writable) { if (writable != null) writable.readWrite(this); } void exchangeAll(Iterable<? extends ByteIO> writables) { if (writables != null) for (writable : writables) exchange(writable); } }
Began life as a copy of #1035632
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035757 |
Snippet name: | StringHead - string I/O class (can read and write, dev.) |
Eternal ID of this version: | #1035757/10 |
Text MD5: | aad93ae69b47ac08c224c984ef5ea29e |
Transpilation MD5: | bff6141b86abcfd7d4b92de0f0070c44 |
Author: | stefan |
Category: | javax / io |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-07-22 04:21:55 |
Source code size: | 1210 bytes / 56 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 145 / 243 |
Version history: | 9 change(s) |
Referenced in: | [show references] |