るりまサーチ

最速Rubyリファレンスマニュアル検索!
471件ヒット [1-100件を表示] (0.033秒)
トップページ > クエリ:IO[x] > クエリ:line[x] > クエリ:write[x]

別のキーワード

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

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

...くは IO.open を見てください。

@param path ファイル名文字列
@param string 書き込む文字列
@param offset 書き込み開始位置
@param opts ファイルを開くときのキーワード引数

//emlist[例][ruby]{
text = "This is line one\nThis is line two\nThis is line thre...
...e\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 (39192.0)

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

...くは IO.open を見てください。

@param path ファイル名文字列
@param string 書き込む文字列
@param offset 書き込み開始位置
@param opts ファイルを開くときのキーワード引数

//emlist[例][ruby]{
text = "This is line one\nThis is line two\nThis is line thre...
...e\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 (38408.0)

基本的な入出力機能のためのクラスです。

...基本的な入出力機能のためのクラスです。


File::Constants は、File から IO へ移動しました。

===[a:m17n] 多言語化と IO のエンコーディング

IO
オブジェクトはエンコーディングを持ちます。
エンコーディングの影響を受けるメ...
... IO のエンコーディングの影響をうけます。
詳しくは「io_encoding」を参照して下さい。
以下がテキスト読み込みメソッドです。

* IO.foreach
* IO.readlines
* IO#each_line
* IO#lines
* IO#gets
* IO#getc
* IO#ungetc
* IO#read
* IO#readchar
* IO#rea...
...* IO#read(size)
* IO#read_nonblock
* IO#readpartial
* IO#sysread

また書き込みメソッド IO#write IO のエンコーディングの影響を受けます。
IO
のすべての書き込みメソッドは内部で IO#write を呼びますので、
書き込みメソッドはすべて IO...
... IO のエンコーディングの影響をうけます。
詳しくは「io_encoding」を参照して下さい。
以下がテキスト読み込みメソッドです。

* IO.foreach
* IO.readlines
* IO#each_line
* IO#gets
* IO#getc
* IO#ungetc
* IO#read
* IO#readchar
* IO#readline
* IO#...

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

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

...]{
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,\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] (27208.0)

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

...]{
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,\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] (27208.0)

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

...]{
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,\rline2,...
...\r\nline3,\n")
IO
.readlines("testfile", chomp: true) # => ["line1,\rline2,", "line3,"]
IO
.readlines("testfile", "\r", chomp: true) # => ["line1,", "line2,", "\nline3,\n"]
//}...

IO#readlines(limit, chomp: false) -> [String] (27190.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...aise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例][ruby]{
IO
.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3...
...e") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}

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

@see $/, IO#gets...

IO#readlines(rs = $/, chomp: false) -> [String] (27190.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...aise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例][ruby]{
IO
.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3...
...e") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}

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

@see $/, IO#gets...

IO#readlines(rs, limit, chomp: false) -> [String] (27190.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...aise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例][ruby]{
IO
.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3...
...e") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}

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

@see $/, IO#gets...

IO.readlines(path, limit, opts={}) -> [String] (27154.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] (27154.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] (27154.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(limit) -> [String] (27148.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...aise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例][ruby]{
IO
.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3...
...) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}


@see $/, IO#gets...

IO#readlines(rs = $/) -> [String] (27148.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...aise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例][ruby]{
IO
.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3...
...) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}


@see $/, IO#gets...

IO#readlines(rs, limit) -> [String] (27148.0)

データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。

...aise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例][ruby]{
IO
.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3...
...) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}


@see $/, IO#gets...

絞り込み条件を変える

IO#each_line(limit, chomp: false) {|line| ... } -> self (24396.0)

IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。

...
IO
の現在位置から 1 行ずつ文字列として読み込み、それを引数として
与えられたブロックを実行します。

ブロックが与えられなかった場合は、自身から生成した
Enumerator オブジェクトを返します。

テキスト読み込みメソ...
...@raise IOError 自身が読み込み用にオープンされていなければ発生します。

//emlist[例: 引数なし][ruby]{
IO
.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...")
f = File.new("testfile")
f.each { |line| p "#{f.lineno}: #{line}" }
#...
...=> "1: This is line one,\n"
# "2: This is line two,\n"
# "3: This is line three,\n"
# "4: And so on..."
//}
//emlist[例: 行の区切りに半角カンマ、最大読み取りバイト数に 10 を指定][ruby]{
IO
.write("testfile", "This is line one,This is line two,This is line three,And so on......
<< 1 2 3 ... > >>