Libraryless. Click here for Pure Java version (2664L/17K).
static IterableIterator<S> toLines(File f) { ret linesFromFile(f); } static List<String> toLines(String s) { List<String> lines = new ArrayList<String>(); if (s == null) return lines; int start = 0; while (true) { int i = toLines_nextLineBreak(s, start); if (i < 0) { if (s.length() > start) lines.add(s.substring(start)); break; } lines.add(s.substring(start, i)); if (s.charAt(i) == '\r' && i+1 < s.length() && s.charAt(i+1) == '\n') i += 2; else ++i; start = i; } return lines; } static int toLines_nextLineBreak(String s, int start) { int n = s.length(); for (int i = start; i < n; i++) { char c = s.charAt(i); if (c == '\r' || c == '\n') return i; } return -1; }
Began life as a copy of #2000326
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1001950 |
Snippet name: | toLines (function) |
Eternal ID of this version: | #1001950/4 |
Text MD5: | 592ac762ff1e4b02b6942fddf9975432 |
Transpilation MD5: | b8863a3fec0b2a046b035d0595085606 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-05-27 13:20:11 |
Source code size: | 793 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 853 / 4702 |
Version history: | 3 change(s) |
Referenced in: | [show references] |