Gestionnaire de fichiers - Editer - /opt/cpanel/ea-ruby24/root/usr/share/ri/system/IO/read-i.ri
Arrière
U:RDoc::AnyMethod[iI" read:ETI"IO#read;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I".Reads _length_ bytes from the I/O stream.;To:RDoc::Markup::BlankLine o; ; [I"6_length_ must be a non-negative integer or +nil+.;T@o; ; [I"=If _length_ is a positive integer, +read+ tries to read ;TI":_length_ bytes without any conversion (binary mode). ;TI"LIt returns +nil+ if an EOF is encountered before anything can be read. ;TI"LFewer than _length_ bytes are returned if an EOF is encountered during ;TI"the read. ;TI"HIn the case of an integer _length_, the resulting string is always ;TI"in ASCII-8BIT encoding.;T@o; ; [I"<If _length_ is omitted or is +nil+, it reads until EOF ;TI"<and the encoding conversion is applied, if applicable. ;TI"MA string is returned even if EOF is encountered before any data is read.;T@o; ; [I"GIf _length_ is zero, it returns an empty string (<code>""</code>).;T@o; ; [ I"3If the optional _outbuf_ argument is present, ;TI">it must reference a String, which will receive the data. ;TI"LThe _outbuf_ will contain only the received data after the method call ;TI".even if it is not empty at the beginning.;T@o; ; [ I"AWhen this method is called at end of file, it returns +nil+ ;TI"0or <code>""</code>, depending on _length_: ;TI"E+read+, <code>read(nil)</code>, and <code>read(0)</code> return ;TI"<code>""</code>, ;TI"><code>read(<i>positive_integer</i>)</code> returns +nil+.;T@o:RDoc::Markup::Verbatim; [I"f = File.new("testfile") ;TI")f.read(16) #=> "This is line one" ;TI" ;TI"# read whole file ;TI"open("file") do |f| ;TI"J data = f.read # This returns a string even if the file is empty. ;TI" # ... ;TI" end ;TI" ;TI")# iterate over fixed length records ;TI"&open("fixed-record-file") do |f| ;TI"" while record = f.read(256) ;TI" # ... ;TI" end ;TI" end ;TI" ;TI"-# iterate over variable length records, ;TI"4# each record is prefixed by its 32-bit length ;TI")open("variable-record-file") do |f| ;TI" while len = f.read(4) ;TI"4 len = len.unpack("N")[0] # 32-bit length ;TI"N record = f.read(len) # This returns a string even if len is 0. ;TI" end ;TI" end ;T:@format0o; ; [I"CNote that this method behaves like the fread() function in C. ;TI"GThis means it retries to invoke read(2) system calls to read data ;TI"/with the specified length (or until EOF). ;TI"LThis behavior is preserved even if <i>ios</i> is in non-blocking mode. ;TI"F(This method is non-blocking flag insensitive as other methods.) ;TI"AIf you need the behavior like a single read(2) system call, ;TI"9consider #readpartial, #read_nonblock, and #sysread.;T: @fileI" io.c;T:0@omit_headings_from_table_of_contents_below0I"@ios.read([length [, outbuf]]) -> string, outbuf, or nil ;T0[ I"(p1 = v1, p2 = v2);T@SFI"IO;TcRDoc::NormalClass00
| ver. 1.4 |
Github
|
.
| PHP 8.0.30 | Génération de la page: 0.05 |
proxy
|
phpinfo
|
Réglages