how jvm read byte by byte and character by character in i/o streams, readers
posted 10 years ago
good morning to all,
i would like to know how the jvm reads "hello world" text in a file when using stremas and readers in io package. how internally jvm takes for each character while reading from files in both byte streams and character streams.
Hello Ravindar, your question is a bit vague. What exactly do you want to know? The JVM just uses the services of the underlying operating system to read files.
Do you want to know how the JVM does the conversion from bytes to characters? That can be quite complicated. The Java type char holds Unicode characters, and conversion from bytes to characters is done via a character set. See the API documentation of the package java.nio.charset, which contains classes like Charset, CharsetDecoder and CharsetEncoder, which are classes that know how to convert bytes to and from Unicode characters.