Libraryless. Click here for Pure Java version (2947L/19K).
1 | static CloseableCharSequence iso8859_readOnlyFileAsCharSequence(File f, O... _) { |
2 | optPar bool noToString; // if set, only subsequences can be converted to a string |
3 | optPar long start = 0; |
4 | |
5 | int l = toInt_safe(l(f)-start); |
6 | RandomAccessFile raf = randomAccessFileForReading(f); |
7 | ret new CloseableCharSequence { |
8 | public int length() { ret l; } |
9 | public char charAt(int i) ctex { raf.seek(start+i); ret (char) raf.readByte(); } |
10 | public CharSequence subSequence(int from, int to) { ret substringObject(this, from, to); } |
11 | toString { |
12 | if (noToString) fail("Too big for converting to string"); |
13 | ret charSequenceToStringByChar(this); |
14 | } |
15 | public void close { _close(raf); } |
16 | }; |
17 | } |
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: | #1029255 |
Snippet name: | iso8859_readOnlyFileAsCharSequence |
Eternal ID of this version: | #1029255/11 |
Text MD5: | f90a5d0b57149c25687d0c89071e461c |
Transpilation MD5: | 2f4c09ab62f4ad7053dff115a39132c8 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-07-29 21:46:03 |
Source code size: | 723 bytes / 17 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 241 / 366 |
Version history: | 10 change(s) |
Referenced in: | [show references] |