Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

bufferedreader in java

Name: ­ 2009-02-25 22:27

is this the correct use of bufferedReader if I'm only using it once?

String s = BufferedReader(new InputStreamReader(System.in)).newLine();

Name: Anonymous 2009-02-25 23:13

>>1
Almost. You need to call close() on the BufferedReader after you're done with it, which means you need to keep a reference to it.

try {
  BufferedReader buffa = new BufferedReader(new InputStreamReader(System.in));
  String s = buffa.readLine();
  buffa.close();
} catch (IOException e) {
  e.printStackTrace();
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List