【发布时间】:2015-10-12 18:30:12
【问题描述】:
我的扫描仪使用分隔符读取我的文本文件时遇到问题。我试图将每个字符串保存在一个数组中,但是当我打印它时,数组保持为空......我知道为什么
Scanner s = new Scanner(file);
s.useDelimiter("@");
int length = (upperBound - lowerBound)+1;
String [] Entries = new String[length];
for(int i=0; i < length; i++)
{
Entries[i] = s.next();
}
//When I print this the array location is empty:(
System.out.println(Entries[0]);
这是我的文本文件的内容:
The Germans occupy the rump Czech lands@Germany invades Denmark and Norway@Nazi Germany and its Axis partners invade the Soviet Union@
【问题讨论】:
-
嗨!我帮不了你,因为我不知道这是哪种编程语言。添加语言标签!
-
我认为upperBound - lowerBound 一定是非正数
标签: arrays string file delimiter