るりまサーチ

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

別のキーワード

  1. stringio read
  2. _builtin read
  3. csv read
  4. io read
  5. tuple read

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

IO.write(path, string, **opts) -> Integer (18134.0)

path で指定されるファイルを開き、string を書き込み、 閉じます。

...キーワード引数はファイルを開くときに使われ、エンコーディングなどを指定することができます。
詳しくは IO.open を見てください。

@param path ファイル名文字列
@param string 書き込む文字列
@param offset 書き込み開始位置
@par...
...ine three\nAnd so on...\n"
IO
.write("testfile", text) # => 66
IO
.write("testfile", "0123456789", 20) #=> 10
IO
.read("testfile")
# => "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n"
IO
.write("testfile", "0123456789") #=> 10
IO
.read("testfile")...
...# => "0123456789"
//}

@see IO.binwrite...

IO.write(path, string, offset=nil, **opts) -> Integer (18134.0)

path で指定されるファイルを開き、string を書き込み、 閉じます。

...キーワード引数はファイルを開くときに使われ、エンコーディングなどを指定することができます。
詳しくは IO.open を見てください。

@param path ファイル名文字列
@param string 書き込む文字列
@param offset 書き込み開始位置
@par...
...ine three\nAnd so on...\n"
IO
.write("testfile", text) # => 66
IO
.write("testfile", "0123456789", 20) #=> 10
IO
.read("testfile")
# => "This is line one\nThi0123456789two\nThis is line three\nAnd so on...\n"
IO
.write("testfile", "0123456789") #=> 10
IO
.read("testfile")...
...# => "0123456789"
//}

@see IO.binwrite...

IO.binread(path, length = nil, offset = 0) -> String | nil (6114.0)

path で指定したファイルを open し、offset の所まで seek し、 length バイト読み込みます。

...例][ruby]{
IO
.write("testfile", "This is line one\nThis is line two\nThis is line three\nAnd so on...\n")
IO
.binread("testfile") # => "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
IO
.binread("testfile", 20) # => "This is line one\nThi"
IO
.binread("testfile...
...", 20, 10) # => "ne one\nThis is line "
//}

@see IO.read...

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

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

...ist[例][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", "l...
...ine1,\rline2,\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 = $/, chomp: false, opts={}) -> [String] (6114.0)

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

...ist[例][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", "l...
...ine1,\rline2,\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, chomp: false, opts={}) -> [String] (6114.0)

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

...ist[例][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", "l...
...ine1,\rline2,\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 で指定されたファイルを全て読み込んで、その各行を要素としてもつ配列を返します。

...、ファイルの読み込みに失敗した場合に発生します。

//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 = $/, opts={}) -> [String] (6108.0)

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, opts={}) -> [String] (6108.0)

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.select(reads, writes = [], excepts = [], timeout = nil) -> [[IO]] | nil (214.0)

select(2) を実行します。

...ちの IO オブジェクトの中から準備ができたものを
それぞれ配列にして、配列の配列として返します。
タイムアウトした時には nil を返します。

@param reads 入力待ちする IO オブジェクトの配列を渡します。

@param writes 出力...
...待ちする IO オブジェクトの配列を渡します。

@param excepts 例外待ちする IO オブジェクトの配列を渡します。

@param timeout タイムアウトまでの時間を表す数値または nil を指定します。数値で指定したときの単位は秒です。nil...
...定した時には IO がどれかひとつレディ状態になるまで待ち続けます。

@raise IOError 与えられた IO オブジェクトが閉じられていた時に発生します。

@raise Errno::EXXX select(2) に失敗した場合に発生します。

rp, wp = IO.pipe
mesg = "pi...

絞り込み条件を変える

IO.pipe {|read_io, write_io| ... } -> object (210.0)

pipe(2) を実行して、相互につながった2つの IO オブジェクトを要素とする配列を返します。

...相互につながった2つの
IO
オブジェクトを要素とする配列を返します。

戻り値の配列は最初の要素が読み込み側で、次の要素が書き込み側です。

ブロックが渡された場合は、そのブロックに2つの IO オブジェクトが渡され...
...ソッドの返り値となります。
ブロック終了時に IO オブジェクトがもし close されていないならば
close します(close されていてるオブジェクトはそのままです)。

得られる2つの IO オブジェクトのエンコーディングを引数で指...
...ングなどを設定するキーワード引数(see IO.new)

@raise Errno::EXXX IO オブジェクトの作成に失敗した場合に発生します。

r, w = IO.pipe
p [r, w] # => [#<IO:0x401b90f8>, #<IO:0x401b7718>]
Thread.new do
w.puts "foo"
w.close
end
p r.gets...

IO.pipe(enc_str, **opts) {|read_io, write_io| ... } -> object (210.0)

pipe(2) を実行して、相互につながった2つの IO オブジェクトを要素とする配列を返します。

...相互につながった2つの
IO
オブジェクトを要素とする配列を返します。

戻り値の配列は最初の要素が読み込み側で、次の要素が書き込み側です。

ブロックが渡された場合は、そのブロックに2つの IO オブジェクトが渡され...
...ソッドの返り値となります。
ブロック終了時に IO オブジェクトがもし close されていないならば
close します(close されていてるオブジェクトはそのままです)。

得られる2つの IO オブジェクトのエンコーディングを引数で指...
...ングなどを設定するキーワード引数(see IO.new)

@raise Errno::EXXX IO オブジェクトの作成に失敗した場合に発生します。

r, w = IO.pipe
p [r, w] # => [#<IO:0x401b90f8>, #<IO:0x401b7718>]
Thread.new do
w.puts "foo"
w.close
end
p r.gets...

IO.pipe(ext_enc) {|read_io, write_io| ... } -> object (210.0)

pipe(2) を実行して、相互につながった2つの IO オブジェクトを要素とする配列を返します。

...相互につながった2つの
IO
オブジェクトを要素とする配列を返します。

戻り値の配列は最初の要素が読み込み側で、次の要素が書き込み側です。

ブロックが渡された場合は、そのブロックに2つの IO オブジェクトが渡され...
...ソッドの返り値となります。
ブロック終了時に IO オブジェクトがもし close されていないならば
close します(close されていてるオブジェクトはそのままです)。

得られる2つの IO オブジェクトのエンコーディングを引数で指...
...ングなどを設定するキーワード引数(see IO.new)

@raise Errno::EXXX IO オブジェクトの作成に失敗した場合に発生します。

r, w = IO.pipe
p [r, w] # => [#<IO:0x401b90f8>, #<IO:0x401b7718>]
Thread.new do
w.puts "foo"
w.close
end
p r.gets...
<< 1 2 3 ... > >>