本文整理匯總了Java中java.io.BufferedReader.skip方法的典型用法代碼示例。如果您正苦於以下問題:Java BufferedReader.skip方法的具體用法?Java BufferedReader.skip怎麽用?Java BufferedReader.skip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.io.BufferedReader
的用法示例。
在下文中一共展示了BufferedReader.skip方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadRequestsFromFile
import java.io.BufferedReader; //導入方法依賴的package包/類
/**
* loads the requests from the cache file if present
*/
private boolean loadRequestsFromFile(int numbersToLoad, long startOffset, int firstID) {
int id = firstID;
long offset = startOffset < 0 ? 0 : startOffset;
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(mRequestStoreFile), "UTF-8"));
reader.skip(offset);
try {
String line;
int ind = 0;
//set offset for first id
mIDs.put(id, offset);
while ((line = reader.readLine()) != null && ind++ < numbersToLoad && mURLCache.get(id) == null) {
if (mIDs.get(id) == null)
WebtrekkLogging.log("File is more then existed keys. Error. Key:" + id + " offset:" + offset);
//put URL and increment id
mLoaddedIDs.put(id++, line);
offset += (line.length() + System.getProperty("line.separator").length());
//set offset of next id if exists
if (mIDs.get(id) != null && (mLatestSavedURLID >= id || mLatestSavedURLID == -1) )
mIDs.put(id, offset);
}
} finally {
reader.close();
}
} catch (Exception e) {
WebtrekkLogging.log("cannot load backup file '" + mRequestStoreFile.getAbsolutePath() + "'", e);
return false;
}
return true;
}
示例2: initConsistentReader
import java.io.BufferedReader; //導入方法依賴的package包/類
private void initConsistentReader() throws IOException {
consistentReader = new BufferedReader(createReader());
if (isSkipFirstLine && !this.offsets.isEmpty()) {
consistentReader.skip(this.offsets.get(0)); //TODO: any other ideas how skip header?
}
}