本文整理汇总了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?
}
}