DumDumDiary

2011-09-26

[]川上未映子

乳と卵(らん) (文春文庫)

乳と卵(らん) (文春文庫)

2011-09-21

[]笹本稜平

不正侵入 (光文社文庫)

不正侵入 (光文社文庫)

2011-08-23

[]平野啓一郎

決壊〈上〉 (新潮文庫)

決壊〈上〉 (新潮文庫)

決壊〈下〉 (新潮文庫)

決壊〈下〉 (新潮文庫)

2011-08-15

[]メモ:ファイル->DTOインスタンス動的生成)

/**

* ファイル -> DTOインスタンス動的生成).

*/

public List toBeans(String fileName, String className) throws Exception {

Class clazz = getClass().getClassLoader().loadClass(className);

List<Xxx> list = new ArrayList<Xxx>();

FileReader fr = null;

BufferedReader br = null;

try {

fr= new FileReader(fileName);

br = new BufferedReader(fr);

String line;

while *1 != null) {

Object instance = clazz.newInstance();

if (instance instanceof ***) {

((Xxx) instance).パースメソッド(line);

list.add((Xxx) instance);

} else {

throw new IllegalArgumentException(className

+ " は Xxx を実装したクラスではない。");

}

}

} finally {

if (br != null) try { br.close(); } catch (IOException e) {}

if (fr != null) try { fr.close(); } catch (IOException e) {}

}

return list;

}

*1:line = br.readLine(