java - Scanner.skip() NoSuchElementException
问题描述
从文件中读取,这是名为 next 的方法的内容。它接收一个字符串当前参数并检查文件中该字符串的外观,然后跳过它并返回下一个字符串。
但不幸的是,我一直没有收到这样的元素异常。
有什么帮助吗?
代码:
Scanner cleanReader = new Scanner(cleanText);
String next;
while(cleanReader.hasNextLine())
{
Scanner crChild = new Scanner(cleanReader.nextLine());
if(current == null)
{
next = crChild.next();
//System.out.println(str);
return next;
}
else
{
while(crChild.hasNext())
{
cleanReader.skip(current);
next = crChild.next();
return next;
}
}
}
cleanReader.close();
解决方案
推荐阅读
- c++ - C++ SafeSingleton 3 级继承
- jestjs - 如何在 Jest 的方法中模拟嵌套实例方法?
- view - 如果我的视图按钮被visualforce页面覆盖,如何配置案例提要
- security - 将后端身份验证令牌附加到响应 URL 时是否存在安全问题?
- flutter - GridView builder和carousal不会在颤动中滚动
- asp.net - 如何在 sass (node-sass) 中设置网格模板区域
- maven - 如何在 Mule 项目中使用同一连接器的多个版本
- python - 使用 selenium 在 Selenium Python 中处理警报
- javascript - 如何将也有数组的自定义数据导出到 Excel?
- android - 检查 android 设备是否具有“绘制其他应用程序”功能