るりまサーチ

最速Rubyリファレンスマニュアル検索!
77件ヒット [1-77件を表示] (0.033秒)

別のキーワード

  1. io popen
  2. io pipe
  3. io each
  4. io each_line
  5. io readlines

クラス

キーワード

検索結果

IO#clone -> IO (15.0)

レシーバと同じ IO を参照する新しい IO オブジェクトを返します。 参照しているファイル記述子は dup(2) されます。

...しいフリーズされていない IO を返します。

@raise IOError 既に close されていた場合に発生します。

//emlist[例][ruby]{
clone_io = nil
IO.write("testfile", "test")
File.open("testfile") do |io|
clone_io = io.clone
end
clone_io.read # => "test"
clone_io.close
//}...

IO#dup -> IO (15.0)

レシーバと同じ IO を参照する新しい IO オブジェクトを返します。 参照しているファイル記述子は dup(2) されます。

...しいフリーズされていない IO を返します。

@raise IOError 既に close されていた場合に発生します。

//emlist[例][ruby]{
clone_io = nil
IO.write("testfile", "test")
File.open("testfile") do |io|
clone_io = io.clone
end
clone_io.read # => "test"
clone_io.close
//}...

IO#read(length = nil, outbuf = "") -> String | nil (9.0)

length バイト読み込んで、その文字列を返します。

...負の場合に発生します。

第二引数を指定した read の呼び出しでデータが空であった場合
(read が nil を返す場合)、outbuf は空文字列になります。

outbuf = "x" * 20;
io =
File.open("/dev/null")
p io.read(10,outbuf)
p outbuf
=> nil
""...

IO#set_encoding(enc_str, **opts) -> self (9.0)

IO のエンコーディングを設定します。

...oding オブジェクトを指定します。

@param int_enc 内部エンコーディングを表す文字列か Encoding オブジェクトを指定します。
@param opts エンコーディング変換のオプション
例:
io =
File.open(file)
io.set_encoding("ASCII-8BIT", "EUC-JP")...
...coding オブジェクトを指定します。

@param int_enc 内部エンコーディングを表す文字列か Encoding オブジェクトを指定します。
@param opts エンコーディング変換のオプション
例:
io =
File.open(file)
io.set_encoding("ASCII-8BIT", "EUC-JP")...

IO#set_encoding(ext_enc) -> self (9.0)

IO のエンコーディングを設定します。

...oding オブジェクトを指定します。

@param int_enc 内部エンコーディングを表す文字列か Encoding オブジェクトを指定します。
@param opts エンコーディング変換のオプション
例:
io =
File.open(file)
io.set_encoding("ASCII-8BIT", "EUC-JP")...
...coding オブジェクトを指定します。

@param int_enc 内部エンコーディングを表す文字列か Encoding オブジェクトを指定します。
@param opts エンコーディング変換のオプション
例:
io =
File.open(file)
io.set_encoding("ASCII-8BIT", "EUC-JP")...

絞り込み条件を変える

IO#set_encoding(ext_enc, int_enc, **opts) -> self (9.0)

IO のエンコーディングを設定します。

...oding オブジェクトを指定します。

@param int_enc 内部エンコーディングを表す文字列か Encoding オブジェクトを指定します。
@param opts エンコーディング変換のオプション
例:
io =
File.open(file)
io.set_encoding("ASCII-8BIT", "EUC-JP")...
...coding オブジェクトを指定します。

@param int_enc 内部エンコーディングを表す文字列か Encoding オブジェクトを指定します。
@param opts エンコーディング変換のオプション
例:
io =
File.open(file)
io.set_encoding("ASCII-8BIT", "EUC-JP")...

IO#sysread(maxlen, outbuf = "") -> String (9.0)

read(2) を用いて入力を行ない、入力されたデータを 含む文字列を返します。stdio を経由しないので gets や getc や eof? などと混用すると思わぬ動作 をすることがあります。

...数を指定した sysread の呼び出しでデータが空であった場
合(sysread が例外 EOFError を発生させる場合)、
outbuf は空文字列になります。

outbuf = "x" * 20;
io =
File.open("/dev/null")
p((io.sysread(10,outbuf) rescue nil))
p outbuf
=> nil
""...