This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Minhaj kaimkhani wrote:but it will read 1 char each time.
Right, readChar() would read just one char at a time. I was looking for a readChars(). But there is no such method. I was just wondering that without such a method, how would you read something(a String) written with writeChars() ?
Writes every character in the string s, to the output stream, in order, two bytes per character. If s is null, a NullPointerException is thrown. If s.length is zero, then no characters are written. Otherwise, the character s is written first, then s, and so on; the last character written is s[s.length-1]. For each character, two bytes are actually written, high-order byte first, in exactly the manner of the writeChar method.
Yes. Just use the writeObject() method to write an object and the readObject() meth
Paul, I think that will be serialization.
Of course it will be serialization. There is no reason to use an ObjectOutputStream if you don't plan to use serialization. If you just want to write primitives and Strings, then a DataOutputStream is a better choice.