问题描述
|
try {
Scanner in = new Scanner(new File(\"text.txt\"));
Formatter out = new Formatter(\"text1.txt\");
in.useDelimiter(\",\");
int num = in.nextInt();//this line throws null exception
for(int i = 0; i < num && in.hasNext(); i++)
{
out.format(\"%s\",\"#string \\n\" + i );
out.format(\"%s\",in.next());
}
out.close();
}
catch (Exception e) {
System.out.print(e.getMessage());
}
输入为:
4
hello,my,name,is
4是单词数。
输出必须是:
hello my name is
但是它抛出了异常,误差ѭ3。
有什么问题
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)