List of usage examples for org.apache.poi.ss.usermodel Workbook getNumberOfSheets
int getNumberOfSheets();
From source file:org.alanwilliamson.openbd.plugin.spreadsheet.functions.SpreadsheetInfo.java
License:Open Source License
public cfData execute(cfSession _session, List<cfData> parameters) throws cfmRunTimeException { cfSpreadSheetData spreadsheet = null; spreadsheet = (cfSpreadSheetData) parameters.get(0); Workbook workbook = spreadsheet.getWorkBook(); cfStructData s = new cfStructData(); /*/* w w w .ja v a 2s .c om*/ * Sheet details */ s.setData("sheets", new cfNumberData(workbook.getNumberOfSheets())); cfArrayData sheetArr = cfArrayData.createArray(1); for (int x = 0; x < workbook.getNumberOfSheets(); x++) { String name = workbook.getSheetName(x); if (name == null) name = ""; sheetArr.addElement(new cfStringData(name)); } s.setData("sheetnames", sheetArr); /* * Workbook type */ if (workbook instanceof XSSFWorkbook) { s.setData("spreadsheettype", new cfStringData("xlsx")); } else { s.setData("spreadsheettype", new cfStringData("xls")); } /* * XSSFWorkbook */ if (workbook instanceof XSSFWorkbook) { XSSFWorkbook xSSFWorkbook = (XSSFWorkbook) workbook; CoreProperties cP = xSSFWorkbook.getProperties().getCoreProperties(); s.setData("category", new cfStringData(cP.getCategory())); s.setData("subject", new cfStringData(cP.getSubject())); s.setData("title", new cfStringData(cP.getTitle())); s.setData("revision", new cfStringData(cP.getRevision())); s.setData("author", new cfStringData(cP.getCreator())); s.setData("description", new cfStringData(cP.getDescription())); if (cP.getLastPrinted() != null) s.setData("lastprinted", new cfDateData(cP.getLastPrinted())); if (cP.getModified() != null) s.setData("lastsaved", new cfDateData(cP.getModified())); if (cP.getCreated() != null) s.setData("creationdate", new cfDateData(cP.getCreated())); } else { HSSFWorkbook hSSFWorkbook = (HSSFWorkbook) workbook; DocumentSummaryInformation dSummary = hSSFWorkbook.getDocumentSummaryInformation(); if (dSummary == null) { s.setData("category", cfStringData.EMPTY_STRING); s.setData("company", cfStringData.EMPTY_STRING); s.setData("manager", cfStringData.EMPTY_STRING); } else { s.setData("category", new cfStringData(dSummary.getCategory())); s.setData("company", new cfStringData(dSummary.getCompany())); s.setData("manager", new cfStringData(dSummary.getManager())); } SummaryInformation sInformation = hSSFWorkbook.getSummaryInformation(); if (sInformation == null) { s.setData("author", cfStringData.EMPTY_STRING); s.setData("comments", cfStringData.EMPTY_STRING); s.setData("keywords", cfStringData.EMPTY_STRING); s.setData("lastauthor", cfStringData.EMPTY_STRING); s.setData("title", cfStringData.EMPTY_STRING); s.setData("subject", cfStringData.EMPTY_STRING); } else { s.setData("author", new cfStringData(sInformation.getAuthor())); s.setData("comments", new cfStringData(sInformation.getComments())); s.setData("keywords", new cfStringData(sInformation.getKeywords())); s.setData("lastauthor", new cfStringData(sInformation.getLastAuthor())); s.setData("title", new cfStringData(sInformation.getTitle())); s.setData("subject", new cfStringData(sInformation.getSubject())); if (sInformation.getCreateDateTime() != null) s.setData("creationdate", new cfDateData(sInformation.getCreateDateTime())); if (sInformation.getLastSaveDateTime() != null) s.setData("lastsaved", new cfDateData(sInformation.getLastSaveDateTime())); if (sInformation.getLastPrinted() != null) s.setData("lastprinted", new cfDateData(sInformation.getLastPrinted())); } } return s; }
From source file:org.alfresco.repo.web.scripts.person.UserCSVUploadPost.java
License:Open Source License
private void processSpreadsheetUpload(Workbook wb, List<Map<QName, String>> users) throws IOException { if (wb.getNumberOfSheets() > 1) { logger.info("Uploaded Excel file has " + wb.getNumberOfSheets() + " sheets, ignoring all except the first one"); }/*from ww w . jav a 2 s. com*/ int firstRow = 0; Sheet s = wb.getSheetAt(0); DataFormatter df = new DataFormatter(); String[][] data = new String[s.getLastRowNum() + 1][]; // If there is a heading freezepane row, skip it PaneInformation pane = s.getPaneInformation(); if (pane != null && pane.isFreezePane() && pane.getHorizontalSplitTopRow() > 0) { firstRow = pane.getHorizontalSplitTopRow(); logger.debug("Skipping excel freeze header of " + firstRow + " rows"); } // Process each row in turn, getting columns up to our limit for (int row = firstRow; row <= s.getLastRowNum(); row++) { Row r = s.getRow(row); if (r != null) { String[] d = new String[COLUMNS.length]; for (int cn = 0; cn < COLUMNS.length; cn++) { Cell cell = r.getCell(cn); if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) { d[cn] = df.formatCellValue(cell); } } data[row] = d; } } // Handle the contents processSpreadsheetUpload(data, users); }
From source file:org.apache.any23.plugin.officescraper.ExcelExtractor.java
License:Apache License
private void processWorkbook(URI documentURI, Workbook wb, ExtractionResult er) { for (int sheetIndex = 0; sheetIndex < wb.getNumberOfSheets(); sheetIndex++) { final Sheet sheet = wb.getSheetAt(sheetIndex); final URI sheetURI = getSheetURI(documentURI, sheet); er.writeTriple(documentURI, excel.containsSheet, sheetURI); er.writeTriple(sheetURI, RDF.TYPE, excel.sheet); writeSheetMetadata(sheetURI, sheet, er); for (Row row : sheet) { final URI rowURI = getRowURI(sheetURI, row); er.writeTriple(sheetURI, excel.containsRow, rowURI); er.writeTriple(rowURI, RDF.TYPE, excel.row); writeRowMetadata(rowURI, row, er); for (Cell cell : row) { writeCell(rowURI, cell, er); }//from w w w .ja v a2s . com } } }
From source file:org.apache.any23.plugin.officescraper.XSSFWorkbookTest.java
License:Apache License
private void verifyResource(String resource) throws IOException { final InputStream document = this.getClass().getResourceAsStream(resource); final Workbook wb; if (resource.endsWith(".xlsx")) { wb = new XSSFWorkbook(document); } else if (resource.endsWith("xls")) { wb = new HSSFWorkbook(document); } else {/*from w w w . ja v a 2 s . com*/ throw new IllegalArgumentException("Unsupported extension for resource " + resource); } Assert.assertEquals(2, wb.getNumberOfSheets()); Sheet sheet; for (int sheetIndex = 0; sheetIndex < wb.getNumberOfSheets(); sheetIndex++) { sheet = wb.getSheetAt(sheetIndex); int rowcount = 0; for (Row row : sheet) { rowcount++; int cellcount = 0; for (Cell cell : row) { cellcount++; logger.debug(String.format("cell [%d, %d]: %s", cell.getRowIndex(), cell.getColumnIndex(), cell.getStringCellValue())); verifyContent(sheetIndex, cell.getRowIndex(), cell.getColumnIndex(), cell.getStringCellValue()); } Assert.assertEquals(3, cellcount); } Assert.assertEquals(3, rowcount); } }
From source file:org.apache.metamodel.excel.DefaultSpreadsheetReaderDelegate.java
License:Apache License
@Override public Schema createSchema(String schemaName) { final MutableSchema schema = new MutableSchema(schemaName); final Workbook wb = ExcelUtils.readWorkbook(_resource); try {// www. j ava2s . c o m for (int i = 0; i < wb.getNumberOfSheets(); i++) { final Sheet currentSheet = wb.getSheetAt(i); final MutableTable table = createTable(wb, currentSheet); table.setSchema(schema); schema.addTable(table); } return schema; } finally { FileHelper.safeClose(wb); } }
From source file:org.bbreak.excella.core.BookController.java
License:Open Source License
/** * // w w w . jav a 2 s. c om * * @param workbook ?? */ public BookController(Workbook workbook) { this.workbook = workbook; // ??? int numOfSheets = workbook.getNumberOfSheets(); for (int sheetCnt = 0; sheetCnt < numOfSheets; sheetCnt++) { String sheetName = workbook.getSheetName(sheetCnt); sheetNames.add(sheetName); } }
From source file:org.bbreak.excella.reports.exporter.ReportBookExporter.java
License:Open Source License
public void export(Workbook book, BookData bookdata) throws ExportException { // ()//from w w w . j av a 2 s. co m SortedSet<Integer> deleteSheetIndexs = new TreeSet<Integer>(Collections.reverseOrder()); for (int i = 0; i < book.getNumberOfSheets(); i++) { String sheetName = book.getSheetName(i); if (sheetName.startsWith(PoiUtil.TMP_SHEET_NAME)) { deleteSheetIndexs.add(i); } } for (int index : deleteSheetIndexs) { book.removeSheetAt(index); } if (configuration != null) { // output(book, bookdata, configuration); } }
From source file:org.bbreak.excella.reports.exporter.ReportBookExporterTest.java
License:Open Source License
/** * {@link org.bbreak.excella.reports.exporter.ReportBookExporter#export(org.apache.poi.ss.usermodel.Workbook, org.bbreak.excella.core.BookData)} ???? *///ww w .j av a2 s . c om @Test public void testExport() { Workbook book = getWorkbook(); ReportBookExporter exporter = new ReportBookExporter() { @Override public String getExtention() { return null; } @Override public String getFormatType() { return null; } @Override public void output(Workbook book, BookData bookdata, ConvertConfiguration configuration) throws ExportException { } }; exporter.setConfiguration(new ConvertConfiguration("")); try { exporter.export(book, null); } catch (ExportException e) { e.printStackTrace(); fail(e.toString()); } assertEquals(4, book.getNumberOfSheets()); for (int i = 0; i < book.getNumberOfSheets(); i++) { String sheetName = book.getSheetName(i); assertFalse(sheetName.startsWith(PoiUtil.TMP_SHEET_NAME)); } }
From source file:org.bbreak.excella.reports.processor.ReportProcessor.java
License:Open Source License
/** * ???????//from w w w. j a v a2 s.c o m * * @param workbook * @param reportBook * @return ????? */ private Set<String> expandTemplate(Workbook workbook, ReportBook reportBook) { Set<String> delSheetNames = new TreeSet<String>(Collections.reverseOrder()); Set<String> useSheetNames = new HashSet<String>(); // ???? for (ReportSheet reportSheet : reportBook.getReportSheets()) { if (reportSheet != null) { if (reportSheet.getSheetName().equals(reportSheet.getTemplateName())) { // ????? int lastSheetIndex = workbook.getNumberOfSheets() - 1; workbook.setSheetOrder(reportSheet.getSheetName(), lastSheetIndex); useSheetNames.add(reportSheet.getTemplateName()); } else { int tempIdx = workbook.getSheetIndex(reportSheet.getTemplateName()); Sheet sheet = workbook.cloneSheet(tempIdx); ReportsUtil.copyPrintSetup(workbook, tempIdx, sheet); workbook.setSheetName(workbook.getSheetIndex(sheet), reportSheet.getSheetName()); delSheetNames.add(reportSheet.getTemplateName()); } } } // ? for (int i = 0; i < workbook.getNumberOfSheets(); i++) { Sheet sheet = workbook.getSheetAt(i); if (!isOutputSheet(sheet, reportBook)) { delSheetNames.add(sheet.getSheetName()); } } delSheetNames.removeAll(useSheetNames); // ????? return delSheetNames; }
From source file:org.bbreak.excella.reports.tag.ImageParamParserTest.java
License:Open Source License
/** * {@link org.bbreak.excella.reports.tag.ImageParamParser#parse(org.apache.poi.ss.usermodel.Sheet, org.apache.poi.ss.usermodel.Cell, java.lang.Object)} ???? */// w w w . j a v a2s . co m @Test public void testParseSheetCellObject() { // ----------------------- // []? // ----------------------- Workbook workbook = getWorkbook(); Sheet sheet1 = workbook.getSheetAt(0); ImageParamParser parser = new ImageParamParser(); ReportsParserInfo reportsParserInfo = new ReportsParserInfo(); reportsParserInfo.setParamInfo(createTestData(ImageParamParser.DEFAULT_TAG)); try { parseSheet(parser, sheet1, reportsParserInfo); } catch (ParseException e) { fail(e.toString()); } // ??? Set<Integer> delSheetIndexs = new TreeSet<Integer>(Collections.reverseOrder()); for (int i = 0; i < workbook.getNumberOfSheets(); i++) { if (i != 0) { delSheetIndexs.add(i); } } for (Integer i : delSheetIndexs) { workbook.removeSheetAt(i); } // ??? Workbook expectedWorkbook = getExpectedWorkbook(); Sheet expectedSheet = expectedWorkbook.getSheet("Sheet1"); try { // ? ReportsTestUtil.checkSheet(expectedSheet, sheet1, false); } catch (ReportsCheckException e) { fail(e.getCheckMessagesToString()); } finally { // ????????????? String tmpDirPath = System.getProperty("user.dir") + "/work/test/"; // System.getProperty( "java.io.tmpdir"); File file = new File(tmpDirPath); if (!file.exists()) { file.mkdirs(); } try { String filepath = null; if (version.equals("2007")) { filepath = tmpDirPath + "ImageParamParserTest1.xlsx"; } else { filepath = tmpDirPath + "ImageParamParserTest1.xls"; } PoiUtil.writeBook(workbook, filepath); log.info("????????" + filepath); } catch (IOException e) { fail(e.toString()); } } // ----------------------- // [] // ----------------------- workbook = getWorkbook(); Sheet sheet2 = workbook.getSheetAt(1); parser = new ImageParamParser("$Image"); reportsParserInfo = new ReportsParserInfo(); reportsParserInfo.setParamInfo(createTestData("$Image")); try { parseSheet(parser, sheet2, reportsParserInfo); } catch (ParseException e) { fail(e.toString()); } // ??? delSheetIndexs.clear(); for (int i = 0; i < workbook.getNumberOfSheets(); i++) { if (i != 1) { delSheetIndexs.add(i); } } for (Integer i : delSheetIndexs) { workbook.removeSheetAt(i); } // ??? expectedWorkbook = getExpectedWorkbook(); expectedSheet = expectedWorkbook.getSheet("Sheet2"); try { // ? ReportsTestUtil.checkSheet(expectedSheet, sheet2, false); } catch (ReportsCheckException e) { fail(e.getCheckMessagesToString()); } finally { // ????????????? String tmpDirPath = System.getProperty("user.dir") + "/work/test/"; // System.getProperty( "java.io.tmpdir");; File file = new File(tmpDirPath); if (!file.exists()) { file.mkdir(); } try { String filepath = null; if (version.equals("2007")) { filepath = tmpDirPath + "ImageParamParserTest2.xlsx"; } else { filepath = tmpDirPath + "ImageParamParserTest2.xls"; } PoiUtil.writeBook(workbook, filepath); log.info("????????" + filepath); } catch (IOException e) { fail(e.toString()); } } String filename = this.getClass().getSimpleName(); if (version.equals("2007")) { filename = filename + "_err.xlsx"; } else if (version.equals("2003")) { filename = filename + "_err.xls"; } URL url = this.getClass().getResource(filename); String path = null; try { path = URLDecoder.decode(url.getFile(), "UTF-8"); } catch (UnsupportedEncodingException e) { Assert.fail(); } // ----------------------- // []? // ----------------------- workbook = getWorkbook(path); Sheet sheet3 = workbook.getSheetAt(2); parser = new ImageParamParser(); reportsParserInfo = new ReportsParserInfo(); reportsParserInfo.setParamInfo(createTestData(ImageParamParser.DEFAULT_TAG)); try { parseSheet(parser, sheet3, reportsParserInfo); fail("?????????"); } catch (ParseException e) { } // ----------------------- // []???? // ----------------------- workbook = getWorkbook(); Sheet sheet4 = workbook.getSheetAt(2); parser = new ImageParamParser(); reportsParserInfo = new ReportsParserInfo(); reportsParserInfo.setParamInfo(createTestData(ImageParamParser.DEFAULT_TAG)); try { parseSheet(parser, sheet4, reportsParserInfo); } catch (ParseException e) { fail(e.toString()); } // ??? expectedWorkbook = getExpectedWorkbook(); expectedSheet = expectedWorkbook.getSheet("Sheet4"); try { // ? ReportsTestUtil.checkSheet(expectedSheet, sheet4, false); } catch (ReportsCheckException e) { fail(e.getCheckMessagesToString()); } // ---------------------------------------------------------------------- // []1 / ?? / ??? // ---------------------------------------------------------------------- workbook = getWorkbook(); Sheet sheet5 = workbook.getSheetAt(INDEX_OF_SHEET5); parser = new ImageParamParser(); reportsParserInfo = new ReportsParserInfo(); reportsParserInfo.setParamInfo(createPluralTestData(ImageParamParser.DEFAULT_TAG)); try { parseSheet(parser, sheet5, reportsParserInfo); } catch (ParseException e) { fail(e.toString()); } // ??? delSheetIndexs.clear(); for (int i = 0; i < workbook.getNumberOfSheets(); i++) { if (i != INDEX_OF_SHEET5) { delSheetIndexs.add(i); } } for (Integer i : delSheetIndexs) { workbook.removeSheetAt(i); } // ??? expectedWorkbook = getExpectedWorkbook(); expectedSheet = expectedWorkbook.getSheet("Sheet5"); try { // ? ReportsTestUtil.checkSheet(expectedSheet, sheet5, false); } catch (ReportsCheckException e) { fail(e.getCheckMessagesToString()); } finally { // ????????????? String tmpDirPath = System.getProperty("user.dir") + "/work/test/"; // System.getProperty( "java.io.tmpdir"); File file = new File(tmpDirPath); if (!file.exists()) { file.mkdirs(); } try { String filepath = null; if (version.equals("2007")) { filepath = tmpDirPath + "ImageParamParserTest3.xlsx"; } else { filepath = tmpDirPath + "ImageParamParserTest3.xls"; } PoiUtil.writeBook(workbook, filepath); log.info("????????" + filepath); } catch (IOException e) { fail(e.toString()); } } // ---------------------------------------------------------------------- // []1 / ?? / ?1 // ---------------------------------------------------------------------- workbook = getWorkbook(); Sheet sheet6 = workbook.cloneSheet(INDEX_OF_SHEET5); parser = new ImageParamParser(); reportsParserInfo = new ReportsParserInfo(); reportsParserInfo.setParamInfo(createPluralTestData(ImageParamParser.DEFAULT_TAG)); try { parseSheet(parser, sheet6, reportsParserInfo); } catch (ParseException e) { fail(e.toString()); } // ??? delSheetIndexs.clear(); for (int i = 0; i < workbook.getNumberOfSheets(); i++) { if (i != workbook.getNumberOfSheets() - 1) { delSheetIndexs.add(i); } } for (Integer i : delSheetIndexs) { workbook.removeSheetAt(i); } // ??? expectedWorkbook = getExpectedWorkbook(); expectedSheet = expectedWorkbook.cloneSheet(INDEX_OF_SHEET5); try { // ? ReportsTestUtil.checkSheet(expectedSheet, sheet6, false); } catch (ReportsCheckException e) { fail(e.getCheckMessagesToString()); } finally { // ????????????? String tmpDirPath = System.getProperty("user.dir") + "/work/test/"; // System.getProperty( "java.io.tmpdir"); File file = new File(tmpDirPath); if (!file.exists()) { file.mkdirs(); } try { String filepath = null; if (version.equals("2007")) { filepath = tmpDirPath + "ImageParamParserTest4.xlsx"; } else { filepath = tmpDirPath + "ImageParamParserTest4.xls"; } PoiUtil.writeBook(workbook, filepath); log.info("????????" + filepath); } catch (IOException e) { fail(e.toString()); } } // ---------------------------------------------------------------------- // [] / ?? / ? // ---------------------------------------------------------------------- workbook = getWorkbook(); for (int i = 1; i <= PLURAL_COPY_FIRST_NUM_OF_SHEETS; i++) { Sheet sheet = workbook.cloneSheet(INDEX_OF_SHEET5); parser = new ImageParamParser(); reportsParserInfo = new ReportsParserInfo(); reportsParserInfo.setParamInfo(createPluralTestData(ImageParamParser.DEFAULT_TAG)); try { parseSheet(parser, sheet, reportsParserInfo); } catch (ParseException e) { fail(e.toString()); } } // ??? delSheetIndexs.clear(); for (int i = 0; i < workbook.getNumberOfSheets(); i++) { if (i < workbook.getNumberOfSheets() - PLURAL_COPY_FIRST_NUM_OF_SHEETS) { delSheetIndexs.add(i); } } for (Integer i : delSheetIndexs) { workbook.removeSheetAt(i); } // ??? expectedWorkbook = getExpectedWorkbook(); for (int i = 1; i <= PLURAL_COPY_FIRST_NUM_OF_SHEETS; i++) { expectedSheet = expectedWorkbook.cloneSheet(INDEX_OF_SHEET5); } try { int startOfTargetSheet = expectedWorkbook.getNumberOfSheets() - PLURAL_COPY_FIRST_NUM_OF_SHEETS; for (int i = 0; i < PLURAL_COPY_FIRST_NUM_OF_SHEETS; i++) { // ? ReportsTestUtil.checkSheet(expectedWorkbook.getSheetAt(startOfTargetSheet + i), workbook.getSheetAt(i), false); } } catch (ReportsCheckException e) { fail(e.getCheckMessagesToString()); } finally { // ????????????? String tmpDirPath = System.getProperty("user.dir") + "/work/test/"; // System.getProperty( "java.io.tmpdir"); File file = new File(tmpDirPath); if (!file.exists()) { file.mkdirs(); } try { String filepath = null; if (version.equals("2007")) { filepath = tmpDirPath + "ImageParamParserTest5.xlsx"; } else { filepath = tmpDirPath + "ImageParamParserTest5.xls"; } PoiUtil.writeBook(workbook, filepath); log.info("????????" + filepath); } catch (IOException e) { fail(e.toString()); } } // ---------------------------------------------------------------------- // [] / ?? / (2)? // ---------------------------------------------------------------------- workbook = getWorkbook(); Sheet sheet = null; int totalNumOfCopies = PLURAL_COPY_FIRST_NUM_OF_SHEETS + PLURAL_COPY_SECOND_NUM_OF_SHEETS; for (int i = 1; i <= totalNumOfCopies; i++) { if (i <= PLURAL_COPY_FIRST_NUM_OF_SHEETS) { sheet = workbook.cloneSheet(INDEX_OF_SHEET5); } else { sheet = workbook.cloneSheet(INDEX_OF_SHEET6); } parser = new ImageParamParser(); reportsParserInfo = new ReportsParserInfo(); reportsParserInfo.setParamInfo(createPluralTestData(ImageParamParser.DEFAULT_TAG)); try { parseSheet(parser, sheet, reportsParserInfo); } catch (ParseException e) { fail(e.toString()); } } // ??? delSheetIndexs.clear(); for (int i = 0; i < workbook.getNumberOfSheets(); i++) { if (i < workbook.getNumberOfSheets() - totalNumOfCopies) { delSheetIndexs.add(i); } } for (Integer i : delSheetIndexs) { workbook.removeSheetAt(i); } // ??? expectedWorkbook = getExpectedWorkbook(); for (int i = 1; i <= totalNumOfCopies; i++) { if (i <= PLURAL_COPY_FIRST_NUM_OF_SHEETS) { expectedSheet = expectedWorkbook.cloneSheet(INDEX_OF_SHEET5); } else { expectedSheet = expectedWorkbook.cloneSheet(INDEX_OF_SHEET6); } } try { int startOfTargetSheet = expectedWorkbook.getNumberOfSheets() - totalNumOfCopies; for (int i = 0; i < totalNumOfCopies; i++) { // ? ReportsTestUtil.checkSheet(expectedWorkbook.getSheetAt(startOfTargetSheet + i), workbook.getSheetAt(i), false); } } catch (ReportsCheckException e) { fail(e.getCheckMessagesToString()); } finally { // ????????????? String tmpDirPath = System.getProperty("user.dir") + "/work/test/"; // System.getProperty( "java.io.tmpdir"); File file = new File(tmpDirPath); if (!file.exists()) { file.mkdirs(); } try { String filepath = null; if (version.equals("2007")) { filepath = tmpDirPath + "ImageParamParserTest6.xlsx"; } else { filepath = tmpDirPath + "ImageParamParserTest6.xls"; } PoiUtil.writeBook(workbook, filepath); log.info("????????" + filepath); } catch (IOException e) { fail(e.toString()); } } }