• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Abt Buffered readers

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can same BufferedrReader instance be used several times in a program to scan different inputs...........sometimes character- sometimes string may be ?

i mean say...for e.g i create one instance of bufferedReader say..."br"
i use for the first time br to scan input from user but now....later in program i again feel need....to scan another input from user....now can i again use br which was now, pointing to previous input ?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can allocate a new BufferedReader object, and use the same variable "br" to point to it; although generally, what you're describing is bad style. Using one variable for different purposes at different times makes code hard to understand.

Unless you put the reading code into a method which accepts a BufferedReader as a parameter; then you can use that one routine to read from many different sources.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic