Libraryless. Click here for Pure Java version (3920L/22K).
1 | asclass ShortInputStream { |
2 | public int read(short[] destination) throws IOException { |
3 | ret read(destination, 0, l(destination)); |
4 | } |
5 | |
6 | public int read(short[] destination, int off, int len) throws IOException { |
7 | int n = 0; |
8 | while (n < len) { |
9 | int i = read(); |
10 | if (i == Int.MIN_VALUE) |
11 | break; |
12 | destination[off+n] = (short) i; |
13 | n++; |
14 | } |
15 | ret n; |
16 | } |
17 | |
18 | public abstract int read() throws IOException; |
19 | |
20 | public void readFully(short[] destination) throws IOException { |
21 | readFully(destination, 0, destination.length); |
22 | } |
23 | |
24 | public void readFully(short[] destination, int offset, int length) throws IOException { |
25 | int read = 0; |
26 | |
27 | while (read < length) { |
28 | int r = read(destination, offset+read, length-read); |
29 | if (r == -1) |
30 | throw new EOFException("Asked to read " + length + " bytes from " + offset + " but hit EoF at " + read); |
31 | else |
32 | read += r; |
33 | } |
34 | } |
35 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1032933 |
Snippet name: | ShortInputStream |
Eternal ID of this version: | #1032933/4 |
Text MD5: | ae1beeb6a4b75b3206795c851a212d26 |
Transpilation MD5: | df443d3f656753baf6d93be2796af33b |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-11 01:41:37 |
Source code size: | 979 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 173 / 285 |
Version history: | 3 change(s) |
Referenced in: | [show references] |