//check the download address whether exist if (!searchDir.exists() && !searchDir.isDirectory()) { searchDir.mkdirs(); System.out.println("Create this folder"); } else { System.out.println("The download address is exist"); }
//try to read the excel file and download the picture from the online. try { List<Map<String, String>> maps = redExcel(args[0]); maps.forEach(System.out::println);
//download the picture here for(inti=0; i < maps.size(); i++){ //System.out.println(maps.get(i).get("Image Link")); downloadPicture(maps.get(i).get("Image Link"), picture_path+"\\"+maps.get(i).get("Image Name")+".jpg"); System.out.println("Successfully download: "+ maps.get(i).get("Image Name")); }
// read the whole Excel XSSFWorkbooksheets=newXSSFWorkbook(in); // get the first Sheet XSSFSheetsheetAt= sheets.getSheetAt(0); ArrayList<Map<String, String>> list = newArrayList<>();
//first row is title row i = 0 XSSFRowtitleRow= sheetAt.getRow(0); // for loop read all data for (inti=1; i < sheetAt.getPhysicalNumberOfRows(); i++) { XSSFRowrow= sheetAt.getRow(i); LinkedHashMap<String, String> map = newLinkedHashMap<>(); // read one for (intindex=0; index < row.getPhysicalNumberOfCells(); index++) { XSSFCelltitleCell= titleRow.getCell(index); XSSFCellcell= row.getCell(index); // cell.setCellType(XSSFCell.CELL_TYPE_STRING); outdated, use the content below instaed cell.setCellType(CellType.STRING);
if (cell.getStringCellValue().equals("")) { continue; } map.put(getString(titleCell), getString(cell));