基於大文字檔案的文字讀取查詢

2021-07-25 08:27:28 字數 1043 閱讀 9125

一、

1、本地磁碟讀取大檔案(可能是本地記事本打不開的文字檔案),並獲取需要的某個資料,顯示一共有多少條資料----大資料文字瀏覽器

public static  int  getline() throws filenotfoundexception, ioexception 

line++;

} fin.close();

sc.close();

return line; //可以返回資料的行數

}

2、載入到記憶體,實現快速查詢  二次賦值實現索引快速讀取讀取檔案

生成索引用到了隨機訪問檔案randomaccessfile及方法 raf.seek(index[line]);

public static  void init(     int  index) throws filenotfoundexception, ioexception

;string path="f:\\data\\1e~001.txt";

inputstream fin=new fileinputstream (path);

scanner sin=new scanner(fin);

while(sin.hasnextline())}}

}

三 、將文字檔案載入記憶體,查詢某乙個資料的詳細內容

public static  void init(string  strs) throws filenotfoundexception, ioexception

else

}fin.close();

sc.close();

system.out.println("init end");

}public static void search(string str, string strs)}}

public static void main(string args) throws ioexception

}

.

讀取文字檔案

void ctestdlg onreadinfo cfile filewrite1 testwrite1.txt cfile modecreate cfile modewrite cfile filewrite2 testwrite2.txt cfile modecreate cfile modew...

讀取文字檔案內容

讀取文字檔案內容 param filepathandname 帶有完整絕對路徑的檔名 param encoding 文字檔案開啟的編碼方式 return 返回文字檔案的內容 public string readtxt string filepathandname,string encoding th...

linux c getline讀取文字檔案

函式原型 istream getline istream is,string str,char delim istream getline istream is,string str 讀取檔案,第乙個按引數delim作為分隔符,第二個以 n 作為分隔符。問題產生 在windows,新建文字文件,輸入...