Skip to content

Instantly share code, notes, and snippets.

@torao
Created February 24, 2012 09:16
Show Gist options
  • Save torao/1899691 to your computer and use it in GitHub Desktop.
Save torao/1899691 to your computer and use it in GitHub Desktop.
/* RandomAccessFile をストリームとして扱いたい時はあるけど、こんな書き方でも環境互換性は
* 保証されるんだっけ? org.apache.hadoop.hdfs.server.common.Storage より
*/
public void read(File from) throws IOException {
RandomAccessFile file = new RandomAccessFile(from, "rws");
FileInputStream in = null;
try {
in = new FileInputStream(file.getFD());
file.seek(0);
Properties props = new Properties();
props.load(in);
getFields(props, this);
} finally {
if (in != null) {
in.close();
}
file.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment