List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook write
private void write(POIFSFileSystem fs) throws IOException
From source file:com.smi.travel.datalayer.view.dao.impl.ARNirvanaImpl.java
private String genReport(List<ARNirvana> arDataList, String fullFileName, List<ARNirvana> ARList) { UtilityFunction util = new UtilityFunction(); String status = ""; SimpleDateFormat df = new SimpleDateFormat(); df.applyPattern("dd/MM/yyyy"); try {/*from w w w .ja va2 s . c om*/ HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet(); int rownum = 0; for (ARNirvana ar : arDataList) { HSSFRow dataRow = sheet.createRow(rownum++); int cellnum = 0; HSSFCell cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getIntreference()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getSalesmanid()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getCustomerid()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getCustomername()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getDivisionid()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getProjectid()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getTranscode()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getTransdate() == null ? "" : util.ConvertString( df.format(util.convertStringToDate(String.valueOf(ar.getTransdate()))))); cell = dataRow.createCell(cellnum++); if (ar.getDuedate() == null) { cell.setCellValue(""); } else { cell.setCellValue(util .ConvertString(df.format(util.convertStringToDate(String.valueOf(ar.getDuedate()))))); } cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getCurrencyid()); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getHomerate())); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getForeignrate())); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getSalesamt())); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getSaleshmamt())); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getVatamt())); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getVathmamt())); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getAramt())); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getArhmamt())); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getVatflag()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getVatid()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getWhtflag()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getWhtid()); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getBasewhtamt())); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getBasewhthmamt())); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getWhtamt())); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getWhthmamt())); cell = dataRow.createCell(cellnum++); if (ar.getYear() == null) { cell.setCellValue(""); } else { cell.setCellValue(ar.getYear()); } cell = dataRow.createCell(cellnum++); if (ar.getPeriod() == null) { cell.setCellValue(""); } else { cell.setCellValue(ar.getPeriod()); } cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getNote()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getSalesaccount1()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getSalesdivision1()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getSalesproject1()); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getSalesamt1())); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getSaleshmamt1())); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getSalesaccount2()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getSalesdivision2()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getSalesproject2()); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getSalesamt2())); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getSaleshmamt2())); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getSalesaccount3()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getSalesdivision3()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getSalesproject3()); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getSalesamt3())); cell = dataRow.createCell(cellnum++); cell.setCellValue(UtilityFunction.getObjectString(ar.getSaleshmamt3())); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getService()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getAraccount()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getPrefix()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getDocumentno()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getArtrans()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getCust_taxid()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getCust_branch() == null ? "" : ar.getCust_branch().toString()); cell = dataRow.createCell(cellnum++); cell.setCellValue(ar.getCompany_branch()); // for(int j =0;j<100;j++){ // sheet.autoSizeColumn(j); // } } FileOutputStream out = new FileOutputStream(new File(fullFileName + ".xls")); workbook.write(out); out.close(); status = "success"; } catch (Exception e) { e.printStackTrace(); for (ARNirvana ar : ARList) { if (!"".equals(status)) { status += ", "; } status += ar.getReceive_detail_id(); } } return status; }
From source file:com.smi.travel.migration.MainMigrate.java
static void exportFileExcel(String filename, HSSFWorkbook wb) { try {/* w w w. ja v a 2 s . co m*/ FileOutputStream out = new FileOutputStream(new File(ExportFilePath + filename + ".xls")); wb.write(out); out.close(); System.out.println("Excel StaffReport written successfully.."); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.softtek.mdm.web.admin.IndexController.java
private void exportExcel(String sheetName, String[] headNames, List<OrganizationModel> lists, HttpServletResponse response) {/*from w w w.j a v a 2s. c o m*/ OutputStream out = null; try { HSSFWorkbook workbook = new HSSFWorkbook(); // HSSFSheet sheet = workbook.createSheet(sheetName); // // HSSFRow rowm = sheet.createRow(0); HSSFCell cellTiltle = rowm.createCell(0); //sheet??getColumnTopStyle()/getStyle()? - ? - ? HSSFCellStyle columnTopStyle = CommUtil.getColumnTopStyle(workbook);//?? sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, (headNames.length - 1))); cellTiltle.setCellStyle(columnTopStyle); cellTiltle.setCellValue(sheetName); // int columnNum = headNames.length; HSSFRow rowRowName = sheet.createRow(2); // 2?() // sheet? for (int n = 0; n < columnNum; n++) { HSSFCell cellRowName = rowRowName.createCell(n); //? cellRowName.setCellType(HSSFCell.CELL_TYPE_STRING); //?? HSSFRichTextString text = new HSSFRichTextString(headNames[n]); cellRowName.setCellValue(text); //? cellRowName.setCellStyle(columnTopStyle); //?? } //?sheet? HSSFDataFormat format = workbook.createDataFormat(); short formatDate = format.getFormat("yyyy-MM-dd hh:mm:ss"); for (int i = 0; i < lists.size(); i++) { HSSFRow row = sheet.createRow(i + 3);// OrganizationModel obj = lists.get(i);//??? /*row.createCell(0).setCellValue(obj.getOrgType());*/ row.createCell(0).setCellValue(obj.getName()); row.createCell(1).setCellValue(obj.getCreateName()); row.createCell(2).setCellValue(obj.getTotalUsers() == null ? 0 : obj.getTotalUsers()); row.createCell(3).setCellValue(obj.getTotalDevices() == null ? 0 : obj.getTotalDevices()); row.createCell(4).setCellValue(obj.getLicenseCount() == null ? 0 : obj.getLicenseCount()); row.createCell(5).setCellValue(obj.getUseUsers() == null ? 0 : obj.getUseUsers()); HSSFCell cell = row.createCell(6); cell.setCellValue(obj.getCreateTime()); HSSFCellStyle cellStyle = workbook.createCellStyle(); cellStyle.setDataFormat(formatDate); cell.setCellStyle(cellStyle); } //?? for (int colNum = 0; colNum < columnNum; colNum++) { int columnWidth = sheet.getColumnWidth(colNum) / 256; for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) { HSSFRow currentRow; //? currentRow = (sheet.getRow(rowNum) == null) ? sheet.createRow(rowNum) : sheet.getRow(rowNum); if (currentRow.getCell(colNum) != null) { HSSFCell currentCell = currentRow.getCell(colNum); if (currentCell.getCellType() == HSSFCell.CELL_TYPE_STRING) { int length = currentCell.getStringCellValue().getBytes().length; if (columnWidth < length) { columnWidth = length; } } } } sheet.setColumnWidth(colNum, (colNum == 0) ? (columnWidth * 256) : ((columnWidth + 10) * 256)); } if (workbook != null) { try { String fileName = "Excel-" + String.valueOf(System.currentTimeMillis()).substring(4, 13) + ".xls"; String headStr = "attachment; filename=\"" + fileName + "\""; response.setContentType("application/octet-stream"); response.setHeader("Content-Disposition", headStr); out = response.getOutputStream(); workbook.write(out); } catch (IOException e) { logger.error(e.getMessage()); } finally { if (out != null) { out.close(); } } } } catch (Exception e) { logger.error(e.getMessage()); } }
From source file:com.sx.finance.OldYahooFinanceJFrame.java
public void writeExcelFile(ArrayList<List<Object>> listDataRaw) { // webbookExcel HSSFWorkbook wb = new HSSFWorkbook(); // webbooksheet,Excelsheet HSSFSheet sheet = wb.createSheet("Data"); // sheet0,poiExcelshort HSSFRow row = sheet.createRow((int) 0); // //from w w w . j a v a 2 s .c o m HSSFCellStyle style = wb.createCellStyle(); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // for (int i = 0; i < title.length; i++) { HSSFCell cell = row.createCell(i); cell.setCellValue(title[i]); cell.setCellStyle(style); } for (int i = 0; i < listDataRaw.size(); i++) { row = sheet.createRow(i + 1); for (int j = 0; j < listDataRaw.get(i).size(); j++) { Object cellData = listDataRaw.get(i).get(j); if (cellData instanceof Long) { row.createCell(j).setCellValue(((Long) cellData).longValue()); } else if (cellData instanceof Double) { row.createCell(j).setCellValue(((Double) cellData).doubleValue()); } else if (cellData instanceof Date) { row.createCell(j).setCellValue((Date) cellData); } else if (cellData instanceof Integer) { row.createCell(j).setCellValue(((Integer) cellData).intValue()); } else { row.createCell(j).setCellValue((String) cellData); } } } try { FileOutputStream fout = new FileOutputStream("D:/work/myprojects/yahooFinance/output/data.xls"); wb.write(fout); fout.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.syncnapsis.utils.data.ExcelHelper.java
License:Open Source License
public static void main(String[] args) throws Exception { String fileName = "testdata.xls"; HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream("src/main/resources/" + fileName)); HSSFSheet sheet = workbook.getSheet("Benutzer"); HSSFRow row = sheet.getRow(0);/*from w w w. j a v a 2 s. co m*/ Cell cell; for (int i = 2; i < 256; i++) { try { cell = row.getCell(i); if (cell == null) cell = row.createCell(i); cell.setCellFormula("IF(ISBLANK(Benutzer!A" + (i - 1) + "),\"\",Benutzer!A" + (i - 1) + ")"); } catch (Exception e) { e.printStackTrace(); } } workbook.write(new FileOutputStream("src/main/resources/new.xls")); }
From source file:com.taobao.itest.dbunit.dataset.excel.XlsDataSetWriter.java
License:Open Source License
/** * Write the specified dataset to the specified Excel document. *//*ww w. ja v a 2s .c o m*/ public void write(IDataSet dataSet, OutputStream out) throws IOException, DataSetException { logger.debug("write(dataSet={}, out={}) - start", dataSet, out); HSSFWorkbook workbook = new HSSFWorkbook(); this.dateCellStyle = createDateCellStyle(workbook); int index = 0; ITableIterator iterator = dataSet.iterator(); while (iterator.next()) { // create the table i.e. sheet ITable table = iterator.getTable(); ITableMetaData metaData = table.getTableMetaData(); HSSFSheet sheet = workbook.createSheet(metaData.getTableName()); // write table metadata i.e. first row in sheet workbook.setSheetName(index, metaData.getTableName()); HSSFRow headerRow = sheet.createRow(0); Column[] columns = metaData.getColumns(); for (int j = 0; j < columns.length; j++) { Column column = columns[j]; HSSFCell cell = headerRow.createCell(j); cell.setCellValue(new HSSFRichTextString(column.getColumnName())); } // write table data for (int j = 0; j < table.getRowCount(); j++) { HSSFRow row = sheet.createRow(j + 1); for (int k = 0; k < columns.length; k++) { Column column = columns[k]; Object value = table.getValue(j, column.getColumnName()); if (value != null) { HSSFCell cell = row.createCell(k); if (value instanceof Date) { setDateCell(cell, (Date) value, workbook); } else if (value instanceof BigDecimal) { setNumericCell(cell, (BigDecimal) value, workbook); } else if (value instanceof Long) { setDateCell(cell, new Date(((Long) value).longValue()), workbook); } else { cell.setCellValue(new HSSFRichTextString(DataType.asString(value))); } } } } index++; } // write xls document workbook.write(out); out.flush(); }
From source file:com.technoetic.xplanner.importer.spreadsheet.SpreadsheetStoryWriter.java
License:Open Source License
/** * Write stories.//from w w w . j a va2 s .c o m * * @param stories * the stories * @throws IOException * Signals that an I/O exception has occurred. */ public void writeStories(final List stories) throws IOException { // assert stories != null; final HSSFWorkbook wb = new HSSFWorkbook(); final HSSFSheet sheet = wb.createSheet("Features"); this.writeHeader(sheet); for (int i = 0; i < stories.size(); i++) { final SpreadsheetStory spreadsheetStory = (SpreadsheetStory) stories.get(i); this.writeStory(sheet, spreadsheetStory, i + 1); } wb.write(this.output); this.output.close(); }
From source file:com.tecnosur.util.Excel.java
public void ExportarMatriculados(CControlmatricula datos, String aula) { try { // Defino el Libro de Excel HSSFWorkbook wb = new HSSFWorkbook(); // Creo la Hoja en Excel Sheet sheet = wb.createSheet("matriculados"); // quito las lineas del libro para darle un mejor acabado sheet.setDisplayGridlines(false); sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 6)); // creo una nueva fila Row trow = sheet.createRow((short) 1); createTituloCell(wb, trow, 0, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "ALUMNOS MATRICULADOS"); Row trow2 = sheet.createRow((short) 3); createTituloCell(wb, trow2, 0, CellStyle.ALIGN_LEFT, CellStyle.VERTICAL_CENTER, "AULA: " + aula); // Creo la cabecera de mi listado en Excel Row row = sheet.createRow((short) 5); // Creo las celdas de mi fila, se puede poner un diseo a la celda_codigo createCell(wb, row, 0, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "CDIGO", true, true); createCell(wb, row, 1, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "ALUMNO", true, true); createCell(wb, row, 2, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "TIPO PAGO", true, true); createCell(wb, row, 3, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "CRONO. PAGO", true, true); createCell(wb, row, 4, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "N CUOT.", true, true); createCell(wb, row, 5, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "MON. MATR.", true, true); createCell(wb, row, 6, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "MON. CUOT.", true, true); // Definimos el tamao de las celdas, podemos definir un tamaa especifico o hacer que //la celda_codigo se acomode segn su tamao Sheet ssheet = wb.getSheetAt(0); ssheet.setColumnWidth(0, 60 * 40); ssheet.setColumnWidth(1, 255 * 40); ssheet.setColumnWidth(2, 90 * 40); ssheet.autoSizeColumn(3);/*from ww w .j a v a 2s .c o m*/ ssheet.autoSizeColumn(4); ssheet.autoSizeColumn(5); ssheet.autoSizeColumn(6); HSSFFont cellFont = wb.createFont(); cellFont.setFontHeightInPoints((short) 8); cellFont.setFontName(HSSFFont.FONT_ARIAL); CellStyle cellStyle = wb.createCellStyle(); cellStyle.setFont(cellFont); cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); cellStyle.setLeftBorderColor((short) 8); cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); cellStyle.setRightBorderColor((short) 8); cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); cellStyle.setBottomBorderColor((short) 8); for (int i = 0; i < datos.size(); i++) { row = sheet.createRow((short) i + 6); Cell celda_codigo = row.createCell(0); celda_codigo.setCellStyle(cellStyle); celda_codigo.setCellValue(datos.get(i).getIdalumno()); Cell celda_alumno = row.createCell(1); celda_alumno.setCellStyle(cellStyle); celda_alumno.setCellValue(datos.get(i).getNom_completo()); Cell celda_tipopago = row.createCell(2); celda_tipopago.setCellStyle(cellStyle); celda_tipopago.setCellValue(datos.get(i).getTipopagante()); Cell celda_crono = row.createCell(3); celda_crono.setCellStyle(cellStyle); celda_crono.setCellValue(datos.get(i).getDesc_cronopagtable()); Cell celda_ncuota = row.createCell(4); celda_ncuota.setCellStyle(cellStyle); celda_ncuota.setCellValue(datos.get(i).getNum_cuota()); Cell celda_matricula = row.createCell(5); celda_matricula.setCellStyle(cellStyle); celda_matricula.setCellValue(datos.get(i).getMonmatricula()); Cell celda_moncuota = row.createCell(6); celda_moncuota.setCellStyle(cellStyle); celda_moncuota.setCellValue(datos.get(i).getMoncuota()); } String strRuta = "TYSAC_Matriculados.xls"; FileOutputStream fileOut = new FileOutputStream(strRuta); wb.write(fileOut); fileOut.close(); Runtime.getRuntime().exec("cmd /c start " + strRuta); } catch (IOException e) { System.out.println("Error de escritura"); e.printStackTrace(); } }
From source file:com.testmax.util.ExcelSheet.java
License:CDDL license
/** * This method is used to modify data from an excel file. * @param sheetIndex - Index of sheet 0,1,2 etc. * @param rowIndex - Index of row 0,1,2 etc. * @param colIndex - Index of col 0,1,2 etc. * @param value - value to be modified/*from w ww .j ava2 s . c o m*/ */ public void modifyExcelCol(int sheetIndex, int rowIndex, int colIndex, String value) { try { FileInputStream fileInputStream = new FileInputStream(this.fileName); POIFSFileSystem fsFileSystem = new POIFSFileSystem(fileInputStream); HSSFWorkbook workBook = new HSSFWorkbook(fsFileSystem); HSSFSheet sheet = workBook.getSheetAt(sheetIndex); sheet.setForceFormulaRecalculation(true); Row row = sheet.getRow(rowIndex); Cell cell = row.getCell(colIndex); cell.setCellValue(value); FileOutputStream fileOut = new FileOutputStream(this.fileName); workBook.write(fileOut); fileOut.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.testmax.util.ExcelSheet.java
License:CDDL license
/** * This method is used to modify data from an excel file. * @param sheetIndex - Index of sheet 0,1,2 etc. * * @param rowColFilter - [filtercol=value]@[modifyCol1=value,modifyCol2=value,...] * filterCol= filter column to identify the row[s] to be modify with a value * modifyCol[n]= column to be modified found by filter col with a value *///from w w w .ja v a 2s. co m public void modifyMultiRowExcel(int sheetIndex, String rowColFilterText) { try { FileInputStream fileInputStream = new FileInputStream(this.fileName); POIFSFileSystem fsFileSystem = new POIFSFileSystem(fileInputStream); HSSFWorkbook workBook = new HSSFWorkbook(fsFileSystem); HSSFSheet sheet = workBook.getSheetAt(sheetIndex); sheet.setForceFormulaRecalculation(true); String[] rowColFilters = rowColFilterText.split(";"); for (String rowColFilter : rowColFilters) { String filter = ""; String modcol = ""; try { filter = rowColFilter.split("@")[0].replace("[", "").replace("]", "").trim(); modcol = rowColFilter.split("@")[1].replace("[", "").replace("]", "").trim(); if (filter != null && !filter.isEmpty()) { String[] filters = filter.split("="); int colIndex = this.getColumnIndex(filters[0]); int rowIndex = this.getRowIndexByColumnValue(colIndex, filters[1]); if (rowIndex >= 0) { Row row = sheet.getRow(rowIndex); String[] colModList = modcol.split(","); for (String eachCol : colModList) { String[] eachList = eachCol.split("="); if (eachList.length > 0) { int modColIndex = this.getColumnIndex(eachList[0]); Cell cell = row.getCell(modColIndex); cell.setCellValue(eachList[1]); } } } } } catch (Exception e) { WmLog.printMessage("ERROR in modifying XLs file =" + this.fileName + " Excel Sheet Index=" + sheetIndex + " Col Filter=" + filter + " Mod Col=" + modcol); // TODO Auto-generated catch block e.printStackTrace(); } } FileOutputStream fileOut = new FileOutputStream(this.fileName); workBook.write(fileOut); fileOut.close(); } catch (IOException e) { WmLog.printMessage("ERROR in modifying XLs file =" + this.fileName + "Excel Sheet Index=" + sheetIndex + " with Excel Row Col Filter=" + rowColFilterText); // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { WmLog.printMessage("ERROR in modifying XLs file =" + this.fileName + "Excel Sheet Index=" + sheetIndex + " with Excel Row Col Filter=" + rowColFilterText); // TODO Auto-generated catch block e.printStackTrace(); } }