サイト内検索:

シーケンシャルファイル読み込み

2010年01月23日更新
お気に入りに登録
VBVCJava開発室 > プログラミング > ファイル/フォルダ処理 > シーケンシャルファイル読み込み
ファイル/フォルダ処理
  1. docファイル存在チェック
  2. docフォルダ存在チェック
  3. docシーケンシャルファイル書き込み
  4. docシーケンシャルファイル読み込み
  5. docランダムアクセスファイル書き込み
  6. docランダムアクセスファイル読み込み
  7. docINIファイル書き込み
  8. docINIファイル読み込み
  9. doc深い階層のフォルダ作成
  10. doc実行ファイル絶対パス取得
  11. docWindowsフォルダ取得
  12. docスタートアップパス取得
  13. doc共通スタートアップパス取得
  14. docデスクトップのパス取得
  15. doc共通デスクトップのパス取得
  16. docプログラムメニューパス取得
  17. doc共通プログラムメニューパス
  18. doc右クリックの送るのパス取得
  19. docお気に入りのパス取得
メインメニュー
  1. docプログラミング
  2. docサーバ構築
  3. docお薦めの技術書籍/参考書
  4. docパソコンショップ
  5. docサーバーショップ
  6. doc周辺機器
  7. docモニター
  8. doc外部媒体
  9. doc自作パソコン用パーツ
  10. doc契約
  11. doc就職・転職・バイト情報

◆説明◆

ファイルから、データを1行ずつ読み込み、strResultに格納するサンプルです。


◆VBの場合◆

Dim strPath As String
Dim intFileNum As Integer
Dim strTemp As String
Dim strResult As String
strPath = "D:\aaa.txt"
If Dir(strPath) <> "" Then
intFileNum = FreeFile
Open strPath For Input As #intFileNum
While Not EOF(intFileNum)
Line Input #intFileNum, strTemp
strResult = strResult + strTemp + vbCrLf
Wend
Close #intFileNum
End If


◆VC++の場合◆

CString strResult = "";
CString strTemp = "";
CStdioFile objFile;
BOOL bolEnd;
if (objFile.Open("D:\\aaa.txt", CFile::modeRead, NULL))
{
while (bolEnd = objFile.ReadString(strTemp), bolEnd)
{
strResult += strTemp + "\r\n";
}
objFile.Close();
}


◆Javaの場合◆

//"java.io.*"をインポートする必要があります。
// import java.io.*;
File objFile;
String strResult = "";
objFile = new File("D:\\aaa.txt");
if (objFile.exists())
{
BufferedReader objReader;
try
{
objReader = new BufferedReader(
new InputStreamReader(
new FileInputStream(objFile)));
while (objReader.ready())
{
strResult += objReader.readLine() + "\r\n";
}
objReader.close();
}
catch (IOException e)
{
}
}


お気に入りに登録