I'm trying to read from an excel file in my java code (IDE is eclipse). My code is attached below. In the line which Iterator is declared i face this error: The type HTMLDocument.Iterator is not generic; it cannot be parameterized with argument . and offers me to "remove type argument." I don't know what the problem is. I have downloaded necessary jar files and added them to my class path but it didn't help.
public static void readMapReduceTasksfromFile(String fileAddress) throws FileNotFoundException
{
try
{
FileOutputStream out = new FileOutputStream("...directory...");
HSSFWorkbook workBook = new HSSFWorkbook();
HSSFSheet sheet = workBook.createSheet();
Iterator <Row> rowIterator = sheet.iterator();//HERE
}
catch(Exception ex)
{
System.out.println("File Not Found");
}
}
Your problem lies in an area of your code, which you have not posted: the import statements. You need to import java.util.Iterator
. Instead it seems like you have imported javax.swing.text.html.HTMLDocument.HTMLDocument.Iterator
.
Remove the erroneous import statement and use the "organize import" function in eclipse, this time make sure to choose java.util.Iterator
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.