!636 !standard functions !quicknew public class main { static String prelude = "public class main {\n" + " static android.app.Activity androidContext; // set from outside\n" + " public static void main(String[] args) throws Exception {\n"; static String postlude = "\n" + " }\n" + "}\n"; public static void main(String[] args) throws IOException { String code = loadTextFile("input/main.java", null); if (code == null) throw new RuntimeException("Nothing to do (no input/main.java)"); code = prelude + code + postlude; code = moveImportsUp(code); saveTextFile("output/main.java", code); } static String moveImportsUp(String s) { List<String> l = toLines(s); new List<String> x; Pattern p = Pattern.compile("^\\s*import\\s"); for (ListIterator<String> i = l.listIterator(); i.hasNext(); ) { String line = i.next(); if (p.matcher(line).find()) { x.add(line); i.remove(); } } x.addAll(l); return fromLines(x); } }
Began life as a copy of #609
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #713 |
Snippet name: | "quickandroid" |
Eternal ID of this version: | #713/1 |
Text MD5: | 9d78782e9e276ba28b0f672adb16d00e |
Author: | stefan |
Category: | |
Type: | JavaX translator |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-08-06 22:30:50 |
Source code size: | 1072 bytes / 37 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 637 / 556 |
Referenced in: | [show references] |