On the other hand, given that it is actually *somewhat* more involved to write
a String to a file than to initialize a memory location with an integer, it
doesn't seem to much to ask someone to write this in the old 99% case:

    FileWriter writer = new FileWriter(file);
    writer.write(string);
    writer.close();

You don't have to be a rocket scientist (who can stretch like rubber and who
rather immodestly calls himself "Mr. Fantastic") to see that the above maps
pretty well onto the good old C sequence of fopen, fwrite, and fclose.

-- Roger


--- Greg Nudelman <[EMAIL PROTECTED]> wrote:
> I just KNEW I was going to get somebody started!
> }:> *evil grin*
> 
> >Well, to be sure, this doesn't give you a filehandle. It gives you an
> output 
> >stream that goes to a filesystem, buffers it, and then provides utility 
> >functions. 
> 
> This is exactly what I am talking about.  Writing to file using Java IO is
> like using a supercomputer to add 1 + 1.  Java is a full-featured language
> for the enterprise.  However, this means that every little thing now
> requires a "sledgehammer" approach to solve it.  
> 
> Although some people (possibly those bitten by radioactive spiders?) will
> froth at the mouth from this thought, I want to state once again: I am  NOT
> trying to solve the world's hunger problems or create peace in the Middle
> East. I am just trying to write a String to a file.  That is all.  99% of
> all the file-writing code just wants to do that and nothing else. Yet this
> "very simple" functionality is not at all that simple in Java.  In fact it
> is awkward for almost everyone who does not deal with this every day.  
> 
> Sure, I can write an OO language that will require all sorts of conversions
> and writers to declare a variable.  Because, hey, I twill not just declare a
> variable!! (to paraphrase your statement above) "It give you an pointer to
> some memory address, allocates memory, and then provides utility functions."
> 
> 
> So a simple statement used 99.99% of the time:
> 
> int i = 0;
> 
> to Joseph's indescribable delight, can now become:
> 
> int i = new IntegerWriter(new MemoryAllocator(new Integer(0)));
> 
> And you do not need to be a super powered freak with adamantine retractable
> claws and a bad temper to see what a waste of time this idle exercise would
> be.  Perl for example, recognizes that, so the code to write to file is very
> simple.  Again, I am NOT talking about 1% of the time when you need to tweak
> something.  I AM talking about a simple function you do 99% of the time.
> You really do not need "Six or a half dozen" ways to do this simple thing.
> 
> To think that Java is perfect for everything and fits every need is
> ridiculous.  Our tools must keep evolving in order to remain useful -- Java
> IO should be no exception.  
> 
> Greg
> 
> -----Original Message-----
> From: Joseph Ottinger [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 21, 2002 11:13 AM
> To: JDJList
> Subject: [jdjlist] RE: Java IO Question
> 
> 
> >From: Greg Nudelman <[EMAIL PROTECTED]>
> 
> >This is one of a few things I find of extreme annoyance in Java.  I do not
> >think any other modern programming language makes you remember:
> >
> >new PrintWriter(new BufferedWriter(new FileWriter("foo.out")));
> >
> >just to get a file handle!! (This is one area where C syntax may even be
> >easier to remember then Java... Scary!)
> 
> Well, to be sure, this doesn't give you a filehandle. It gives you an output
> 
> stream that goes to a filesystem, buffers it, and then provides utility 
> functions. With great power comes great responsibility, and all that rot. 
> Maybe people would remember that if they were all bitten by radioacive 
> spiders and mutated into genetic freaks who would walk on walls.
> 
> >I can never remember the syntax, as I have to write to a file maybe 5-6
> >times a year. And just imagine being tested on an interview by some moron
> >who just looked it up himself that very morning. ("Greg, how do you
> >implement reading the binary file vs. ASCII file in Java?")  So, Mr. 
> >Bright,
> >how often do YOU write that code (without docs and Google)?
> 
> It's orthogonal: streams are binary, writers aren't. Verrrrry difficult to 
> remember.
> 
> >Hmmm... Maybe I should just write my own utility that I can at least
> >remember the syntax for.
> >
> >I'm thinking something like:
> >
> >BufferedFileWriter fw = new BufferedFileWriter("foo.out");
> >fw.write(stringBuffer.toString());
> >
> >
> >For PrintWriters:
> >
> >PrintingBufferedFileWriter pfw = new PrintingBufferedFileWriter("foo.out");
> >pfw.print(stringBuffer.toString());
> >
> >To be fair, I guess I have the advantage - I can go back and refactor my
> >stuff, and I do not need to be v1.0 backward compatible...
> 
> And even fairer, you end up writing classes to do SPECIFICALLY what you 
> want, and if you actually want to step outside your little lines, you end up
> 
> right back where you were, relying on Java's piped input architecture. 
> *shrug* Six or a half dozen, it doesn't matter.
> 
> 
> -----------------------------------------------
> Joseph B. Ottinger       [EMAIL PROTECTED]
> http://enigmastation.com          IT Consultant
> 
> _________________________________________________________________
> MSN Photos is the easiest way to share and print your photos: 
> http://photos.msn.com/support/worldwide.aspx
> 
> 
> To change your membership options, refer to:
> http://www.sys-con.com/java/list.cfm
> 
> 
> To change your membership options, refer to:
> http://www.sys-con.com/java/list.cfm
> 


=====
-- Roger Glover

__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com

To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

Reply via email to