Liste des Groupes | Revenir à co vms |
Also, no dynamic arrays built into the language itself. You need ArrayList()At the level of Java then I think that is to be expected. A
to implement them or things like ByteArrayOutputStream().
There are InputStreamReader to convert from InputStream to Reader andThe java.io package may seem a bit complex, but it makes perfectYou forgot about InputStreamReader() to turn an InputStream into a Reader. :-)
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.
After all, why miss the opportunity to have two parallel sets of APIsBecause InputStream/OutputStream and Reader/Writer are fundamentally
(byte versus character) instead of just the one API ? :-)
Goodness knows why they didn't just add something like String's getBytes()
method to the character APIs or add character support to the byte APIs...
Les messages affichés proviennent d'usenet.