Libraryless. Click here for Pure Java version (100L/1K).
sclass CountingInputStream extends FilterInputStream { long counter; *(InputStream in) { super(in); } @Override public int read() throws IOException { int c = in.read(); if (c >= 0) ++counter; ret c; } @Override public int read(byte[] b) throws IOException { int n = in.read(b); counter += max(n, 0); ret n; } @Override public int read(byte[] b, int off, int len) throws IOException { int n = in.read(b, off, len); counter += max(n, 0); ret n; } long getFilePointer() { ret counter; } }
Began life as a copy of #1029366
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: | #1029436 |
Snippet name: | CountingInputStream |
Eternal ID of this version: | #1029436/2 |
Text MD5: | dfb56a3d1ed855c2ca78fd52a9c10940 |
Transpilation MD5: | c61cfd02360a3e90dff274dbb4e34a5e |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-08-06 12:39:34 |
Source code size: | 584 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 217 / 492 |
Version history: | 1 change(s) |
Referenced in: | [show references] |