void readWrite(SomethingHead head); default byte[] saveToByteArray aka saveAsByteArray aka toByteArray(SomethingHead head default new) { var baos = byteArrayOutputStream(); head.outputStream(baos); readWrite(head); head.finish(); ret baos.toByteArray(); } default S toHexString() { ret main toHexString(toByteArray()); } default File saveToFile(File file) { temp OutputStream out = bufferedFileOutputStream(file); var head = new SomethingHead(out); readWrite(head); head.finish(); ret file; } default selfType load aka fromByteArray(byte[] data) { readWrite(new SomethingHead(new ByteArrayInputStream(data))); this; } default selfType load(File file) { temp InputStream in = bufferedInputStream(file); readWrite(new SomethingHead(in)); this; } default long byteIOLength() { new JustCountingOutputStream out; var head = new SomethingHead(out); readWrite(head); head.finish(); ret out!; }
Began life as a copy of #1035635
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1035662 |
Snippet name: | ByteIO/BitIO helpers |
Eternal ID of this version: | #1035662/12 |
Text MD5: | 1142e628a93e8d78c8b267f0fda4affb |
Author: | stefan |
Category: | javax / io |
Type: | JavaX (incomplete) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-07 00:12:55 |
Source code size: | 975 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 166 / 291 |
Version history: | 11 change(s) |
Referenced in: | [show references] |