Directly from this Java API:
write
public void write(int b)
Writes the specified byte to this stream. If the byte is a newline and automatic flushing is enabled then the flush method will be invoked.
Note that the byte is written as given; to write a character that will be translated according to the platform's default character encoding, use the print(char) or println(char) methods.
I see it's specified the byte is written as given;
However if I try to write(65) I get the A I expected.
What should I write in write() in order to not match the same as it would be with print()?
Could you do any example?
Binary
01000001(thebyte) is the ASCII characterAso you get that when you read as aString.You would need to use
FilterOutputStream.html#write(byte[])to get the same output.
Or whatever type you need
What should I write in write() in order to not match the same as it would be with print()? Could you do any example?
prints
Read the javadoc for the
printmethods. The one above accepts anintandIn either case, bytes are written to the stream, but how they are displayed depends on the how your read them.
Stringhas constructors that accept acharsetNameorCharsetobject. ACharset(as a concept and as a class) is