1

(2,1) サイズの行列を格納するこの HashMap を作成しました。

public static HashMap<String, ArrayList<int[][]>> mresults =
 new HashMap<String, ArrayList<int[][]>>();

この HashMap をファイルに保存して、Ftp 経由で送信できるようにしたいのですが、同時に受信時に、行列を簡単に取得して後で使用できる形式にする必要があります。

なにか提案を?どうもありがとうございました。

4

1 に答える 1

1

マップをシリアル化できます。シリアル化は、オブジェクトをファイルに書き込み、後で復元できるプロセスです。

シリアライズ:

FileOutputStream fos = new FileOutputStream("somefile");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(mresults);
oos.close();
fos.close();

戻す:

FileInputStream fis = new FileInputStream("somefile");
ObjectInputStream ois = new ObjectInputStream(fis);
Map<String, ArrayList<int[][]>> mresults = 
                          (HashMap<String, ArrayList<int[][]>>) ois.readObject();
ois.close();
fis.close();
于 2013-07-24T14:31:12.273 に答える