Re: Enhancement request
On Sat, 6 Sep 2008, Martin Gregorie wrote:
On Fri, 05 Sep 2008 12:40:31 +0100, Tom Anderson wrote:
But yes, this is really an incredibly minor point.
Agreed. Why not pick on something more substantial, such as the tangle of
Readers, InputStreams etc - beast me why I have to jump through nested
hoops just to open a BufferedReader when I have File that identified the
data source. The current way of doing it:
File inf = new File ("myinputfile.txt");
InputStream is = new FileInputStream(inf);
Reader isr = new InputStreamReader(is);
BufferedReader inb = new BufferedReader(isr);
is just plain perverse. When I can release all the resources with
inb.close()
why can't I acquire them with
BufferedReader inb = new BufferedReader(inf);
or
BufferedReader("myinputfile.txt");
Maybe there's a good reason for this, but I'm damned if I can see it.
Because BufferedReaders aren't file-specific. They could be wrapping a
StringReader, and InputStreamReader wrapping a socket InputStream, a
PipedReader, etc. Would you supply constructors for all those uses? Or
privilege files above other cases?
Personally, i don't have a problem with:
BufferedReader inb = new BufferedReader(new FileReader(inf)) ;
Although i do find it shocking that FileReader's constructor doesn't take
a character set.
tom
--
Ed editor textorum probatissimus est -- Cicero, De officiis IV.7