Libraryless. Click here for Pure Java version (51L/1K).
sclass CountingOutputStream extends FilterOutputStream { long counter; *(OutputStream out) { super(out); } @Override public void write(int b) throws IOException { ++counter; out.write(b); } @Override public void write(byte[] b) throws IOException { counter += b.length; out.write(b, 0, b.length); } @Override public void write(byte[] b, int off, int len) throws IOException { if (len == 0) ret; counter += len; out.write(b, off, len); } long getFilePointer() { ret counter; } }
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: | 468 / 795 |
| Version history: | 2 change(s) |
| Referenced in: | #1029436 - CountingInputStream #1033065 - JustCountingOutputStream #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) #1036592 - LimitedOutputStream - OutputStream that fails when writing too much |