Libraryless. Click here for Pure Java version (131L/1K/5K).
1 | !747 |
2 | !actionListener {
|
3 | !721 // thread { |
4 | !x1000805 // awt {
|
5 | |
6 | main {
|
7 | static LogView logView; |
8 | |
9 | !include #1000820 // LogView |
10 | |
11 | psvm {
|
12 | awt {
|
13 | JFrame frame = new JFrame("LogView Test");
|
14 | |
15 | logView = new LogView; |
16 | |
17 | redirectStdOutAndErrTo(logView); |
18 | |
19 | //logView.println("Hello Agnes");
|
20 | //logView.println("Hello Julia");
|
21 | |
22 | frame.add(logView); |
23 | frame.setBounds(100, 100, 500, 400); |
24 | print("Showing");
|
25 | frame.setVisible(true); |
26 | exitOnFrameClose(frame); |
27 | print("Done showing");
|
28 | |
29 | logView.println("Hello Julia");
|
30 | print("yup");
|
31 | } |
32 | } |
33 | |
34 | static void redirectStdOutAndErrTo(final LogView lg) {
|
35 | OutputStream outputStream = new OutputStream() {
|
36 | public void write(int b) {
|
37 | try {
|
38 | lg.print(new String(new byte[] {(byte) b}, "UTF-8")); // This is crap
|
39 | } catch (UnsupportedEncodingException e) {}
|
40 | } |
41 | |
42 | @Override |
43 | public void write(byte[] b, int off, int len) {
|
44 | try {
|
45 | lg.print(new String(b, off, len, "UTF-8")); // This is crap |
46 | } catch (UnsupportedEncodingException e) {}
|
47 | } |
48 | }; |
49 | |
50 | PrintStream ps = new PrintStream(outputStream, true); |
51 | System.setOut(ps); |
52 | System.setErr(ps); |
53 | } |
54 | } |
Began life as a copy of #1000821
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, iveijnkanddl, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
| ID | Author/Program | Comment | Date |
|---|---|---|---|
| 1071 | stefan | OK! | 2015-08-28 20:38:41 |
| Snippet ID: | #1000824 |
| Snippet name: | Redirecting stdout+stderr to LogView test |
| Eternal ID of this version: | #1000824/1 |
| Text MD5: | ae6386a32d3ed017888401e222c2844b |
| Transpilation MD5: | b5fc5f09db73fbb7de41da64f95aa2c6 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-08-28 20:37:56 |
| Source code size: | 1313 bytes / 54 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 1242 / 1304 |
| Referenced in: | [show references] |