> I'm tring to make some simplified file access
With all due respect, you might want to learn Java before you go any
further. There are general concepts and techniques in the language that
you are violating. Type-safety is a big one. You are essentially
providing some that might be an InputStream, might be an OutputStream,
can only be one at a time, and doesn't fail until runtime if you treat
it as the wrong one. This is really a rather pointless exercise. Just
used Reader or InputStream when you want to read, and Writer or
OutputStream when you want to write.
If you need an object that you can use to BOTH read and write a file and
preserve a single file pointer as you do it, then see RandomAccessFile.
However, RandomAccessFile by necessity works only with binary data,
since character encodings can have variable lengths.
A more minor point along the same lines: classes in Java always start
with capital letters. If nothing else, call your classes FileSimple and
File, rather than fileSimple and file. Otherwise, you will just be
confusing people for no reason.
> file.java:59: unreported exception java.io.IOException; must be caught
> or declared to be thrown
> System.out.println(f.slurp());
You need to handle any checked exceptions that may arise. If this is
just simple test code where you want the program to terminate when
there's an error, you can declare that by adding "throws Exception" to
the declaration of main.
> But I have some more fundamental questions too i.e.
> The parent for Writer/Reader is Object.. my problem is that i dont want
[quoted text clipped - 11 lines]
>
> but this still doesnt look too good to me. So what i'm doing wrong.
If you insist on breaking type safety, your code is going to be ugly.
That's really all there is to it. You aren't writing in a scripting
language any more.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
raptor - 21 May 2006 00:28 GMT
With all due respect, you might want to learn Java before you go any
further. There are general concepts and techniques in the language
that
you are violating. Type-safety is a big one. ....
]- thanx, you are right.. but if I want to sacrifice type safety. I
know that i have to follow
strong type rules.. ;] but in many other languages (not only scripting)
i can do this w/o bothering too much ;).
The "super-descriptivness" of java bothers me more than the loose
types.
I'm not tring to argue (or offend you) that my way is better, u know
when u come from other languages u first try to explain yourself the
things in their way.. and after a while u got it right.
I'm still in the phase where I better break things up to learn the way
java expect me to behave ;)
I have been programming in other strong type languages too, but
following the java rules are much unpleasant and in some cases make me
'nuts'. ;)
thanx again for the reply...