1 package jp.co.areaweb.tools.command;
\r
5 * 実際にはメールへの送信を行わずに、指定された情報をファイルに吐き出す。
\r
6 * 「/usr/sbin/sendmail」の代替コマンド
\r
9 public class JSendmail
\r
13 * exp: java jp.co.areaweb.tools.command.JSendmail [parameter]
\r
14 * @param args parameters
\r
15 * @throws Exception 例外
\r
17 static public void main(String[] args) throws Exception {
\r
18 String commandLine = "";
\r
19 for (int i=0; i < args.length; i++) {
\r
23 commandLine += args[i];
\r
27 BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
\r
30 File out = new File("mail.txt");
\r
31 FileOutputStream fo=new FileOutputStream(out);
\r
32 PrintStream ps = new PrintStream(fo);
\r
35 * 標準入力の内容を、出力ファイルに書き出す。
\r
37 ps.println(commandLine);
\r
39 ps.println(convBufferedReader(stdReader));
\r
46 private static String convBufferedReader(BufferedReader reader) throws IOException {
\r
47 if (reader == null) {
\r
50 StringBuffer strbuf = new StringBuffer();
\r
51 for (String line; (line = reader.readLine()) != null; strbuf.append(line +"\n"));
\r
54 return strbuf.toString();
\r