Difference between read() and readline() methods in Java
Difference between read() and readline() methods in Java
Let’s see the differences between read() and readline() methods in Java programming language.
read() vs readline()
The difference between the read() and readline() methods are as follows:
| SNo. | read() | readline() |
| 1. | read() is suitable for reading one byte( single character) | readline() is suitable to read a group of characters at a time. |
| 2. | read() method supports 8-bit ASCII format only. It is suitable for standalone applications. | readline() supports 16-bit UNI code format. It is suitable for web applications. |
| 3. | read() method always returns an int value. | readline() method returns String value. |
| 4. | read() method can be applied to any stream. | readline() is only suitable for BufferedReader. |
| 5. | read() can be terminated whenever a negative number is encountered. | readline() can be terminated whenever null, /n is encountered. |