• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Get name of file from BufferedReader?  RSS feed

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

is there any method to find out the file name to which a BufferedReader is pointing to?
 
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. A BufferedReader may not even be associated with a File.
 
sinatra roger
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay...actually i have written a method which operates on a file through a BUfferedReader passed to it as an argument..i wanted to print the file to which the BufferedReader was associated.
 
Java Cowboy
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that's not possible if you only have the BufferedReader.
 
Sheriff
Posts: 21459
96
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like Steve said, a BufferedReader isn't necessarily wrapped around a FileReader or FileInputStream. It may be wrapped around a Socket's input stream, or even System.in (the last three with InputStreamReader in between).
 
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

thejwal pavithran wrote:okay...actually i have written a method which operates on a file through a BUfferedReader passed to it as an argument..i wanted to print the file to which the BufferedReader was associated.


Then my suggestion would be to create a BufferedFileReader class of your own that extends BufferedReader, for all the reasons already mentioned.

Winston
 
sinatra roger
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instead of passing the BufferedReader, i have changed the method argument to the file name..that serves the purpose for now..
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!