Liste des Groupes | Revenir à co vms |
On 8/20/2024 8:29 AM, Simon Clubley wrote:At times, Java itself seems to "feel" like it has been designed by theorists>
with little real-world experience. All the classes-upon-classes when doing
I/O come to mind here.
JCP is just like ANSI, ISO and ECMA.
>
Java is literally designed by committee.
>
And there are some horror decisions. The compiler API comes
to my mind - it takes 200 lines to do what you can do in 5 lines
in C#.
>
The java.io package may seem a bit complex, but it makes perfect
sense when you learn the structure.
>
The basics is:
>
InputStream - read bytes from anything
FileInputStream - read bytes from file
ByteArrayInputStream - read bytes from byte array
...
OutputStream - write bytes to anything
FileOutputStream - write bytes to file
ByteArrayOutputStream - write bytes to byte array
...
Reader - read chars according to encoding from anything
FileReader - read chars according to encoding from file
CharArrayReader - read chars according to encoding from char array
...
Writer - write chars according to encoding to anything
FileWriter - write chars according to encoding to file
CharArrayWriter - write chars according to encoding to char array
...
>
All very systematic.
>
On top of that there are two convenience classes to work with text
files:
* BufferedReader that wraps any Reader and provides a readLine method
* PrintWriter that wraps any Writer and provides print, println and
printf methods
>
Remember that and you can handle 98% of cases.
>
For the last 2% reading the docs will be needed.
>
Les messages affichés proviennent d'usenet.