1. Read ()
Function: Reads the number of individual characters and returns 1 if it has been read (ranging from 0 to 65535)
Examples are as follows:
and nbsp Byte[ ] buf = new byte[1024]
< Span class= "hl-types" > Int len
< Span class= "Hl-code" > &NBS P While (len = in< Span class= "Hl-code". read (buf ) ) > 0) { //single read count until end return-1
&N Bsp Out. Write (buf 0len
< Span class= "Hl-identifier" > , &NB Sp
< Span class= "hl-brackets" > In.close
, &NB Sp Out. Close
< Span class= "Hl-code" >< Span class= "Hl-identifier" > 2, readLine ()
Function: Reads a line of text.
Examples are as follows:
String str;
&NBS P while ( (strinreadline ( ) ! = null) { //If the previous file is empty, the output
, &NB Sp System. Out. Println (str)
< Span class= "Hl-identifier" > , &NB Sp
The difference between Java read () and ReadLine ()