1 | !636 |
2 | !standard functions |
3 | !quicknew |
4 | |
5 | public class main { |
6 | static String prelude = |
7 | "public class main {\n" + |
8 | " static android.app.Activity androidContext; // set from outside\n" + |
9 | " public static void main(String[] args) throws Exception {\n"; |
10 | static String postlude = "\n" + |
11 | " }\n" + |
12 | "}\n"; |
13 | |
14 | public static void main(String[] args) throws IOException { |
15 | String code = loadTextFile("input/main.java", null); |
16 | if (code == null) |
17 | throw new RuntimeException("Nothing to do (no input/main.java)"); |
18 | code = prelude + code + postlude; |
19 | code = moveImportsUp(code); |
20 | saveTextFile("output/main.java", code); |
21 | } |
22 | |
23 | static String moveImportsUp(String s) { |
24 | List<String> l = toLines(s); |
25 | new List<String> x; |
26 | Pattern p = Pattern.compile("^\\s*import\\s"); |
27 | for (ListIterator<String> i = l.listIterator(); i.hasNext(); ) { |
28 | String line = i.next(); |
29 | if (p.matcher(line).find()) { |
30 | x.add(line); |
31 | i.remove(); |
32 | } |
33 | } |
34 | x.addAll(l); |
35 | return fromLines(x); |
36 | } |
37 | } |
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: | 704 / 631 |
Referenced in: | [show references] |