Libraryless. Click here for Pure Java version (11068L/61K).
static byte[] toByteArray(ByteArrayOutputStream baos) { ret baos == null ? null : baos.toByteArray(); } static byte[] toByteArray(Iterator<? extends Number> it) { new ByteBuffer buf; while (it.hasNext()) buf.add((byte) it.next().intValue()); ret buf.toByteArray(); } static byte[] toByteArray(Cl<? extends Number> it) { int n = l(it), i = 0; byte[] a = new[n]; for (x : it) a[i++] = (byte) x.intValue(); ret a; } static byte[] toByteArray(O o) { if (o == null) null; if (o cast byte[]) ret o; if (o instanceof Iterator) ret toByteArray((Iterator<Number>) o); if (o cast Cl) ret toByteArray((Cl<Number>) o); // not sure what else to put here fail("toByteArray", o); } // Note: Does not rewind the buffer static byte[] toByteArray(java.nio.ByteBuffer buf) { if (buf == null) null; byte[] a = new[buf.remaining()]; buf.get(a); ret a; }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, wnsclhtenguj
No comments. add comment
Snippet ID: | #1018464 |
Snippet name: | toByteArray |
Eternal ID of this version: | #1018464/10 |
Text MD5: | f4b5d07fdae8e1bab67145cc36eedc13 |
Transpilation MD5: | ef522ae7f6cc88ccf8613a87ad77a51e |
Author: | stefan |
Category: | javax / io |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-09-03 13:56:24 |
Source code size: | 924 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 471 / 643 |
Version history: | 9 change(s) |
Referenced in: | [show references] |