Skip to content

Instantly share code, notes, and snippets.

@shikajiro
Created October 2, 2013 03:34
Show Gist options
  • Save shikajiro/6788812 to your computer and use it in GitHub Desktop.
Save shikajiro/6788812 to your computer and use it in GitHub Desktop.
ストリームは開いたら必ず閉じる。
InputStream in = null;
try {
// ②feedjsonを読み込む
in = getAssets().open("feed.json");
BufferedReader buff = new BufferedReader(new InputStreamReader(in));
StringBuilder bld = new StringBuilder();
String line = null;
while ((line = buff.readLine()) != null) {
bld.append(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
//必ずcloseする。
try {
in.close();
} catch (IOException e) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment