01 /*
02 * $Id: MxFormatWrite.java,v 1.5 2008/02/02 05:53:02 koga Exp $
03 *
04 * Copyright (C) 2004 Koga Laboratory. All rights reserved.
05 *
06 */
07 package matxbook.chap14;
08
09 import java.io.FileOutputStream;
10 import java.io.IOException;
11 import java.io.OutputStream;
12
13 import org.mklab.nfc.matrix.DoubleMatrix;
14 import org.mklab.nfc.matx.MatxInteger;
15 import org.mklab.nfc.matx.MatxList;
16 import org.mklab.nfc.matx.MatxString;
17 import org.mklab.nfc.scalar.DoubleComplexNumber;
18
19
20 /**
21 * @author koga
22 * @version $Revision: 1.5 $, 2004/04/26
23 */
24 public class MxFormatWrite {
25
26 /**
27 * メインメソッド
28 *
29 * @param args コマンドライン引数
30 * @throws IOException ファイルに出力できない場合
31 */
32 @SuppressWarnings("nls")
33 public static void main(String[] args) throws IOException {
34 int a = 1;
35 String b = "hello";
36 DoubleMatrix c = new DoubleMatrix(new double[][] { {1, 2}, {3, 4}});
37 MatxList d = new MatxList(new Object[] {new Integer(1), new Double(1.2), new DoubleComplexNumber(3, 4)});
38
39 OutputStream output = new FileOutputStream("data.mx");
40 MatxInteger.writeMxFormat(a, output, "a");
41 MatxString.writeMxFormat(b, output, "b");
42 c.writeMxFormat(output, "c");
43 d.writeMxFormat(output, "d");
44 output.close();
45 }
46 }
|