Libraryless. Click here for Pure Java version (51L/1K).
1 | sclass CountingOutputStream extends FilterOutputStream { |
2 | long counter; |
3 | |
4 | *(OutputStream out) { super(out); } |
5 | |
6 | @Override |
7 | public void write(int b) throws IOException { |
8 | ++counter; |
9 | out.write(b); |
10 | } |
11 | |
12 | @Override |
13 | public void write(byte[] b) throws IOException { |
14 | counter += b.length; |
15 | out.write(b, 0, b.length); |
16 | } |
17 | |
18 | @Override |
19 | public void write(byte[] b, int off, int len) throws IOException { |
20 | if (len == 0) ret; |
21 | counter += len; |
22 | out.write(b, off, len); |
23 | } |
24 | |
25 | long getFilePointer() { ret counter; } |
26 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1029366 |
Snippet name: | CountingOutputStream |
Eternal ID of this version: | #1029366/3 |
Text MD5: | 3fafd6fafd8d704d8f52f56015ecd471 |
Transpilation MD5: | e6c5f94b1ee44afbf051a60ac5501628 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-08-02 18:23:00 |
Source code size: | 565 bytes / 26 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 246 / 535 |
Version history: | 2 change(s) |
Referenced in: | [show references] |