Created
December 19, 2010 12:00
-
-
Save tckz/747286 to your computer and use it in GitHub Desktop.
引数をダンプするダミー
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example; | |
import javax.swing.JEditorPane; | |
import javax.swing.JFrame; | |
import javax.swing.JScrollPane; | |
import java.awt.Container; | |
@SuppressWarnings("serial") | |
public class DummyChan extends JFrame{ | |
DummyChan(String[] args){ | |
JEditorPane editor = new JEditorPane(); | |
StringBuilder sb = new StringBuilder(); | |
sb.append(String.format("num of args=%1d\n", args.length)); | |
for (int i = 0; i < args.length; i++) | |
{ | |
sb.append(String.format("[%1s]%2s\n", i, args[i])); | |
} | |
editor.setText(sb.toString()); | |
editor.setCaretPosition(sb.length()); | |
Container pane = getContentPane(); | |
JScrollPane sc = new JScrollPane(editor); | |
pane.add(sc); | |
} | |
/** | |
* @param args | |
*/ | |
public static void main(String[] args) { | |
DummyChan f = new DummyChan(args); | |
f.setBounds(100, 100, 300, 250); | |
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
f.setTitle("ダミーchan"); | |
f.setVisible(true); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
public class DummyChan2 { | |
/** | |
* @param args | |
* @throws IOException | |
*/ | |
public static void main(String[] args) throws IOException { | |
System.err.printf("num of args=%1d\n", args.length); | |
for (int i = 0; i < args.length; i++) | |
{ | |
System.err.printf("[%1s]%2s\n", i, args[i]); | |
} | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
for(;;) | |
{ | |
String t = br.readLine(); | |
if (t == null) | |
{ | |
break; | |
} | |
System.out.println(t); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment