るりまサーチ

最速Rubyリファレンスマニュアル検索!
72件ヒット [1-72件を表示] (0.056秒)
トップページ > クエリ:file[x] > 種類:特異メソッド[x] > クラス:IO[x] > クエリ:read[x]

別のキーワード

  1. _builtin file?
  2. _builtin file
  3. file umask
  4. file open
  5. file size

ライブラリ

検索結果

IO.read(path, **opt) -> String | nil (18171.0)

path で指定されたファイルを offset 位置から length バイト分読み込んで返します。

...場合は nil を返します。ただし、length に nil か 0 が指定されている場合は、空文字列 "" を返します。例えば、IO.read(空ファイル) は "" を返します。

引数 length が指定された場合はバイナリ読み込みメソッド、そうでない場合...
...e

IO
.open のモードを指定します。
"r" で始まる文字列である必要があります。

: :open_args

IO
.open に渡される引数を配列で指定します。

これらの他、 :external_encoding など
IO
.open のオプション引数が指定できます。

@see IO...
....binread

例:

IO
.read(empty_file) #=> ""
IO
.read(empty_file, 1) #=> nil
IO
.read(one_byte_file, 0, 10) #=> ""
IO
.read(one_byte_file, nil, 10) #=> ""
IO
.read(one_byte_file, 1, 10) #=> nil...

IO.read(path, length = nil, **opt) -> String | nil (18171.0)

path で指定されたファイルを offset 位置から length バイト分読み込んで返します。

...場合は nil を返します。ただし、length に nil か 0 が指定されている場合は、空文字列 "" を返します。例えば、IO.read(空ファイル) は "" を返します。

引数 length が指定された場合はバイナリ読み込みメソッド、そうでない場合...
...e

IO
.open のモードを指定します。
"r" で始まる文字列である必要があります。

: :open_args

IO
.open に渡される引数を配列で指定します。

これらの他、 :external_encoding など
IO
.open のオプション引数が指定できます。

@see IO...
....binread

例:

IO
.read(empty_file) #=> ""
IO
.read(empty_file, 1) #=> nil
IO
.read(one_byte_file, 0, 10) #=> ""
IO
.read(one_byte_file, nil, 10) #=> ""
IO
.read(one_byte_file, 1, 10) #=> nil...

IO.read(path, length = nil, offset = 0, **opt) -> String | nil (18171.0)

path で指定されたファイルを offset 位置から length バイト分読み込んで返します。

...場合は nil を返します。ただし、length に nil か 0 が指定されている場合は、空文字列 "" を返します。例えば、IO.read(空ファイル) は "" を返します。

引数 length が指定された場合はバイナリ読み込みメソッド、そうでない場合...
...e

IO
.open のモードを指定します。
"r" で始まる文字列である必要があります。

: :open_args

IO
.open に渡される引数を配列で指定します。

これらの他、 :external_encoding など
IO
.open のオプション引数が指定できます。

@see IO...
....binread

例:

IO
.read(empty_file) #=> ""
IO
.read(empty_file, 1) #=> nil
IO
.read(one_byte_file, 0, 10) #=> ""
IO
.read(one_byte_file, nil, 10) #=> ""
IO
.read(one_byte_file, 1, 10) #=> nil...

IO.readlines(path, limit, chomp: false, opts={}) -> [String] (6108.0)

path で指定されたファイルを全て読み込んで、その各行を要素としてもつ配列を返します。

...あります。

opts でファイルを開くときのオプションを指定します。エンコーディングなど
を指定できます。
File
.open と同様なのでそちらを参照してください。

@param path ファイル名を表す文字列か "|コマンド名" を指定しま...
...][ruby]{
IO
.write("testfile", "line1\nline2,\nline3\n")
IO
.readlines("testfile") # => ["line1\n", "line2,\n", "line3\n"]
IO
.readlines("testfile", ",") # => ["line1\nline2,", "\nline3\n"]
//}

//emlist[例: rs を取り除く(chomp = true)][ruby]{
IO
.write("testfile", "line1,\r...
...line2,\r\nline3,\n")
IO
.readlines("testfile", chomp: true) # => ["line1,\rline2,", "line3,"]
IO
.readlines("testfile", "\r", chomp: true) # => ["line1,", "line2,", "\nline3,\n"]
//}...

IO.readlines(path, limit, opts={}) -> [String] (6108.0)

path で指定されたファイルを全て読み込んで、その各行を要素としてもつ配列を返します。

...あります。

opts でファイルを開くときのオプションを指定します。エンコーディングなど
を指定できます。
File
.open と同様なのでそちらを参照してください。

@param path ファイル名を表す文字列か "|コマンド名" を指定しま...
...、ファイルの読み込みに失敗した場合に発生します。

//emlist[例][ruby]{
IO
.write("testfile", "line1\nline2,\nline3\n")
IO
.readlines("testfile") # => ["line1\n", "line2,\n", "line3\n"]
IO
.readlines("testfile", ",") # => ["line1\nline2,", "\nline3\n"]
//}...

絞り込み条件を変える

IO.readlines(path, rs = $/, chomp: false, opts={}) -> [String] (6108.0)

path で指定されたファイルを全て読み込んで、その各行を要素としてもつ配列を返します。

...あります。

opts でファイルを開くときのオプションを指定します。エンコーディングなど
を指定できます。
File
.open と同様なのでそちらを参照してください。

@param path ファイル名を表す文字列か "|コマンド名" を指定しま...
...][ruby]{
IO
.write("testfile", "line1\nline2,\nline3\n")
IO
.readlines("testfile") # => ["line1\n", "line2,\n", "line3\n"]
IO
.readlines("testfile", ",") # => ["line1\nline2,", "\nline3\n"]
//}

//emlist[例: rs を取り除く(chomp = true)][ruby]{
IO
.write("testfile", "line1,\r...
...line2,\r\nline3,\n")
IO
.readlines("testfile", chomp: true) # => ["line1,\rline2,", "line3,"]
IO
.readlines("testfile", "\r", chomp: true) # => ["line1,", "line2,", "\nline3,\n"]
//}...

IO.readlines(path, rs = $/, opts={}) -> [String] (6108.0)

path で指定されたファイルを全て読み込んで、その各行を要素としてもつ配列を返します。

...あります。

opts でファイルを開くときのオプションを指定します。エンコーディングなど
を指定できます。
File
.open と同様なのでそちらを参照してください。

@param path ファイル名を表す文字列か "|コマンド名" を指定しま...
...、ファイルの読み込みに失敗した場合に発生します。

//emlist[例][ruby]{
IO
.write("testfile", "line1\nline2,\nline3\n")
IO
.readlines("testfile") # => ["line1\n", "line2,\n", "line3\n"]
IO
.readlines("testfile", ",") # => ["line1\nline2,", "\nline3\n"]
//}...

IO.readlines(path, rs, limit, chomp: false, opts={}) -> [String] (6108.0)

path で指定されたファイルを全て読み込んで、その各行を要素としてもつ配列を返します。

...あります。

opts でファイルを開くときのオプションを指定します。エンコーディングなど
を指定できます。
File
.open と同様なのでそちらを参照してください。

@param path ファイル名を表す文字列か "|コマンド名" を指定しま...
...][ruby]{
IO
.write("testfile", "line1\nline2,\nline3\n")
IO
.readlines("testfile") # => ["line1\n", "line2,\n", "line3\n"]
IO
.readlines("testfile", ",") # => ["line1\nline2,", "\nline3\n"]
//}

//emlist[例: rs を取り除く(chomp = true)][ruby]{
IO
.write("testfile", "line1,\r...
...line2,\r\nline3,\n")
IO
.readlines("testfile", chomp: true) # => ["line1,\rline2,", "line3,"]
IO
.readlines("testfile", "\r", chomp: true) # => ["line1,", "line2,", "\nline3,\n"]
//}...

IO.readlines(path, rs, limit, opts={}) -> [String] (6108.0)

path で指定されたファイルを全て読み込んで、その各行を要素としてもつ配列を返します。

...あります。

opts でファイルを開くときのオプションを指定します。エンコーディングなど
を指定できます。
File
.open と同様なのでそちらを参照してください。

@param path ファイル名を表す文字列か "|コマンド名" を指定しま...
...、ファイルの読み込みに失敗した場合に発生します。

//emlist[例][ruby]{
IO
.write("testfile", "line1\nline2,\nline3\n")
IO
.readlines("testfile") # => ["line1\n", "line2,\n", "line3\n"]
IO
.readlines("testfile", ",") # => ["line1\nline2,", "\nline3\n"]
//}...