while (inFile.hasNextLine()) {
SortedArrayList<Fruit> fruitList = new SortedArrayList<Fruit>();
String marketName = inFile.next();
while (inFile.hasNexLine()) {
String line = inFile.nextLine();
if(line.isEmpty())
break;
else {
Sting fruitName = inFile.next();
int price = inFile.nextInt();
int stock = inFile.nextInt();
fruit = new Fruit(fruitName, price, stock);
fruitList.insert(fruit);
}
}
market = new Market(marketName, fruitList);
marketList.insert(market);
}
I want read text file.
The contents of the text file are as follows:
A_market
apple 1000 11
orange 2000 6
grape 1600 17
B_market
apple 900 20
orange 2100 12
...
Each market cannot know in advance the number of each fruit.
Each market will be separated by blank lines.
How do I identify the blank lines in the text file?
I want blank line on the basis of nested Iterator.
I try isEmpty(), regular expression, Check alphabet, etc..
However, the error is not the will.
Sorry question again then.
What to do to help would be appreciated.