テキストファイルを1行ずつ読み込む方法

Rubyでテキストファイルを1行ずつ読み込むサンプルコードを以下に記します。

htmlinsert(): The given local file does not exist or is not readable.

関連記事

使用環境

$ ruby --version
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
$ lsb_release -d
Description:    Ubuntu 12.04.4 LTS

テキストファイルを1行ずつ読み込むサンプルコード

以下に2種類のサンプルコードを記します。

サンプルコードの実行結果

上記サンプルコードの実行結果を以下に記します。

以上、Rubyでファイルを1行ずつ読み込むサンプルコードでした。

htmlinsert(): The given local file does not exist or is not readable.


添付ファイル: filertxt1.rb 632件 [詳細] filertxt2.rb 622件 [詳細] filetext.txt 618件 [詳細]

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2025-03-12 (水) 11:32:27