List of usage examples for java.util Scanner close
public void close()
From source file:com.axelor.controller.ConnectionToPrestashop.java
public boolean getConnection(String apiKey, String userName) { String message = ""; try {/*from w w w . j a v a 2 s . c om*/ URL url = new URL("http://localhost/client-lib/connection.php?Akey=" + apiKey); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.connect(); InputStream inputStream = connection.getInputStream(); Scanner scan = new Scanner(inputStream); while (scan.hasNext()) { message += scan.nextLine(); } scan.close(); System.out.println("MESSAGE :: " + message); } catch (Exception e) { e.printStackTrace(); } return message == "" ? true : false; }
From source file:de.uzk.hki.da.grid.IrodsCommandLineConnector.java
/** * Gets checksum from ICAT for the newest instance destDao * @author Jens Peters// w w w . j a v a2s. co m * @param destDao * @return */ public String getChecksum(String destDao) { String ret = ""; String commandAsArray[] = new String[] { "ichksum", destDao }; String out = executeIcommand(commandAsArray); if (out.indexOf("ERROR") >= 0) throw new RuntimeException(" Get Checksum of " + destDao + " failed !"); Scanner scanner = new Scanner(out); String data_name = FilenameUtils.getName(destDao); if (data_name.length() > 30) data_name = data_name.substring(0, 30); while (scanner.hasNextLine()) { String line = scanner.nextLine(); if (line.contains(data_name)) { ret = line.substring(38, line.length()); } } scanner.close(); return ret; }
From source file:com.telefonica.euro_iaas.paasmanager.claudia.impl.ClaudiaClientOpenStackImpl.java
private String processGpgKey(String gpgKey) { String processedKey = ""; Scanner scanner = new Scanner(gpgKey); while (scanner.hasNextLine()) { processedKey = processedKey + " " + scanner.nextLine() + "\n"; }/*from w ww . ja va2s . c om*/ scanner.close(); return processedKey; }
From source file:MediaLibrary.java
public MediaLibrary(String jsonFilename) { this.mediaFiles = new HashMap<String, MediaDescription>(); count = 0;// ww w . j a v a2 s. com Scanner ifstr = null; try { ifstr = new Scanner(new FileInputStream(jsonFilename)); StringBuilder sb = new StringBuilder(); while (ifstr.hasNext()) { sb.append(ifstr.next()); } JSONObject obj = new JSONObject(sb.toString()); for (String title : JSONObject.getNames(obj)) { JSONObject tobj = new JSONObject(obj.get(title).toString()); MediaDescription md = new MediaDescription(tobj); mediaFiles.put(md.getTitle(), md); } } catch (FileNotFoundException fnfe) { System.out.println("File not found"); fnfe.printStackTrace(); } finally { ifstr.close(); } }
From source file:org.opentides.persistence.hibernate.MultiTenantSchemaUpdate.java
/** * This is the helper function that initializes the schema and tables. * Initialization is as follows: //from w w w . j a va 2 s . co m * (1) Get the latest initialization sql script. Execute the sql script. * (2) If there is no initialization script, use the hibernate SchemaExport. * * @param tenantId */ private void initializeSchema(Configuration cfg, Connection connection, String schema) { // check if there SQL file under the sslScript folder boolean initialized = false; if (ddlScript != null && ddlScript.exists()) { _log.info("Initializing schema [" + schema + "] using DDL script [" + ddlScript.getFilename() + "]."); InputStream inputStream = null; try { inputStream = ddlScript.getInputStream(); Scanner f = new Scanner(inputStream); StringBuilder stmt = new StringBuilder(); while (f.hasNext()) { String line = f.nextLine(); // ignore comment if (line.startsWith("--")) continue; stmt.append(" ").append(line); if (line.endsWith(";")) { // end of statement, execute then clear connection.createStatement().execute(stmt.toString()); System.out.println(stmt.toString()); stmt.setLength(0); } } f.close(); initialized = true; } catch (SQLException e) { _log.error("Failed to execute sql script for initialization", e); } catch (IOException e) { _log.error("Failed to read sql script for initialization", e); } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { } } } } if (!initialized) { _log.info("Initializing schema [" + schema + "] using SchemaExport. "); SchemaExport export = new SchemaExport(cfg, connection); if (this.logDdl) { String dir = ddlLogs + "/" + DateUtil.convertShortDate(new Date()); _log.info("DDL logs can be found in " + dir + "/schema-" + schema + ".sql"); FileUtil.createDirectory(dir); export.setOutputFile(dir + "/schema-" + schema + ".sql"); export.setDelimiter(";"); } export.execute(this.logDdl, true, false, true); } }
From source file:net.k3rnel.arena.server.GameServer.java
/** * Load pre-existing settings if any//w ww .j av a 2 s .c o m * NOTE: It loads the database password if available. * Password is line after serverName */ private void loadSettings() { System.out.println("Loading settings..."); File foo = new File("res/settings.txt"); if (foo.exists()) { try { Scanner s = new Scanner(foo); m_dbServer = s.nextLine(); m_dbName = s.nextLine(); m_dbUsername = s.nextLine(); m_serverName = s.nextLine(); m_dbPassword = s.nextLine(); if (m_dbPassword.isEmpty() || m_dbPassword.equals(" ")) { ConsoleReader r = new ConsoleReader(); System.out.println("Please enter the required information."); System.out.println("Database Password: "); m_dbPassword = r.readToken(); } s.close(); } catch (Exception e) { e.printStackTrace(); } } else { System.out.println("Settings not found."); getConsoleSettings(); } }
From source file:com.maxl.java.aips2xml.Aips2Xml.java
static void extractPackageInfo() { try {/*from w w w .ja va 2 s .co m*/ long startTime = System.currentTimeMillis(); if (SHOW_LOGS) System.out.print("- Processing packages xls ... "); // Load Swissmedic xls file FileInputStream packages_file = new FileInputStream(FILE_PACKAGES_XLS); // Get workbook instance for XLS file (HSSF = Horrible SpreadSheet Format) HSSFWorkbook packages_workbook = new HSSFWorkbook(packages_file); // Get first sheet from workbook HSSFSheet packages_sheet = packages_workbook.getSheetAt(0); // Iterate through all rows of first sheet Iterator<Row> rowIterator = packages_sheet.iterator(); int num_rows = 0; while (rowIterator.hasNext()) { Row row = rowIterator.next(); if (num_rows > 3) { String swissmedic_no5 = ""; // SwissmedicNo5 registration number (5 digits) String sequence_name = ""; String package_id = ""; String swissmedic_no8 = ""; // SwissmedicNo8 = SwissmedicNo5 + Package id (8 digits) String heilmittel_code = ""; String package_size = ""; String package_unit = ""; String swissmedic_cat = ""; String application_area = ""; String public_price = ""; String exfactory_price = ""; String therapeutic_index = ""; String withdrawn_str = ""; String speciality_str = ""; String plimitation_str = ""; String add_info_str = ""; // Contains additional information separated by ; // 0: Zulassungsnnr, 1: Sequenz, 2: Sequenzname, 3: Zulassunginhaberin, 4: T-Nummer, 5: ATC-Code, 6: Heilmittelcode // 7: Erstzulassung Prparat, 8: Zulassungsdatum Sequenz, 9: Gltigkeitsdatum, 10: Verpackung, 11: Packungsgrsse // 12: Einheit, 13: Abgabekategorie, 14: Wirkstoff, 15: Zusammensetzung, 16: Anwendungsgebiet Prparat, 17: Anwendungsgebiet Sequenz swissmedic_no5 = getAnyValue(row.getCell(0)); // Swissmedic registration number (5 digits) sequence_name = getAnyValue(row.getCell(2)); // Sequence name heilmittel_code = getAnyValue(row.getCell(6)); package_size = getAnyValue(row.getCell(11)); package_unit = getAnyValue(row.getCell(12)); swissmedic_cat = getAnyValue(row.getCell(13)); application_area = getAnyValue(row.getCell(16)); if (row.getCell(10) != null) { package_id = getAnyValue(row.getCell(10)); swissmedic_no8 = swissmedic_no5 + package_id; // Fill in row ArrayList<String> pack = new ArrayList<String>(); pack.add(swissmedic_no5); // 0 pack.add(sequence_name); // 1 pack.add(heilmittel_code); // 2 pack.add(package_size); // 3 pack.add(package_unit); // 4 pack.add(swissmedic_cat); // 5 if (!application_area.isEmpty()) pack.add(application_area + " (Swissmedic)\n"); // 6 = swissmedic + bag else pack.add(""); pack.add(public_price); // 7 pack.add(exfactory_price); // 8 pack.add(therapeutic_index); // 9 pack.add(withdrawn_str); // 10 pack.add(speciality_str); // 11 pack.add(plimitation_str); // 12 pack.add(add_info_str); // 13 package_info.put(swissmedic_no8, pack); } } num_rows++; } long stopTime = System.currentTimeMillis(); if (SHOW_LOGS) { System.out.println( (package_info.size() + 1) + " packages in " + (stopTime - startTime) / 1000.0f + " sec"); } startTime = System.currentTimeMillis(); if (SHOW_LOGS) System.out.print("- Processing atc classes xls ... "); if (DB_LANGUAGE.equals("de")) { // Load ATC classes xls file FileInputStream atc_classes_file = new FileInputStream(FILE_ATC_CLASSES_XLS); // Get workbook instance for XLS file (HSSF = Horrible SpreadSheet Format) HSSFWorkbook atc_classes_workbook = new HSSFWorkbook(atc_classes_file); // Get first sheet from workbook HSSFSheet atc_classes_sheet = atc_classes_workbook.getSheetAt(1); // Iterate through all rows of first sheet rowIterator = atc_classes_sheet.iterator(); num_rows = 0; while (rowIterator.hasNext()) { Row row = rowIterator.next(); if (num_rows > 2) { String atc_code = ""; String atc_class = ""; if (row.getCell(0) != null) { atc_code = row.getCell(0).getStringCellValue().replaceAll("\\s", ""); } if (row.getCell(2) != null) { atc_class = row.getCell(2).getStringCellValue(); } // Build a full map atc code to atc class if (atc_code.length() > 0) { atc_map.put(atc_code, atc_class); } } num_rows++; } } else if (DB_LANGUAGE.equals("fr")) { // Load multilinguagl ATC classes txt file String atc_classes_multi = readFromFile(FILE_ATC_MULTI_LINGUAL_TXT); // Loop through all lines Scanner scanner = new Scanner(atc_classes_multi); while (scanner.hasNextLine()) { String line = scanner.nextLine(); List<String> atc_class = Arrays.asList(line.split(": ")); String atc_code = atc_class.get(0); String[] atc_classes_str = atc_class.get(1).split(";"); String atc_class_french = atc_classes_str[1].trim(); atc_map.put(atc_code, atc_class_french); } scanner.close(); } stopTime = System.currentTimeMillis(); if (SHOW_LOGS) System.out .println((atc_map.size() + 1) + " classes in " + (stopTime - startTime) / 1000.0f + " sec"); // Load Refdata xml file File refdata_xml_file = null; if (DB_LANGUAGE.equals("de")) refdata_xml_file = new File(FILE_REFDATA_PHARMA_DE_XML); else if (DB_LANGUAGE.equals("fr")) refdata_xml_file = new File(FILE_REFDATA_PHARMA_FR_XML); else { System.err.println("ERROR: DB_LANGUAGE undefined"); System.exit(1); } FileInputStream refdata_fis = new FileInputStream(refdata_xml_file); startTime = System.currentTimeMillis(); if (SHOW_LOGS) System.out.print("- Unmarshalling Refdata Pharma " + DB_LANGUAGE + " ... "); JAXBContext context = JAXBContext.newInstance(Pharma.class); Unmarshaller um = context.createUnmarshaller(); Pharma refdataPharma = (Pharma) um.unmarshal(refdata_fis); List<Pharma.ITEM> pharma_list = refdataPharma.getItem(); String smno8; for (Pharma.ITEM pharma : pharma_list) { String ean_code = pharma.getGtin(); if (ean_code.length() == 13) { smno8 = ean_code.substring(4, 12); // Extract pharma corresponding to swissmedicno8 ArrayList<String> pi_row = package_info.get(smno8); // Replace sequence_name if (pi_row != null) { if (pharma.getAddscr().length() > 0) pi_row.set(1, pharma.getDscr() + ", " + pharma.getAddscr()); else pi_row.set(1, pharma.getDscr()); if (pharma.getStatus().equals("I")) { if (DB_LANGUAGE.equals("de")) pi_row.set(10, "a.H."); else if (DB_LANGUAGE.equals("fr")) pi_row.set(10, "p.c."); } } else { if (SHOW_ERRORS) System.err.println(">> Does not exist in BAG xls: " + smno8 + " (" + pharma.getDscr() + ", " + pharma.getAddscr() + ")"); } } else if (ean_code.length() < 13) { if (SHOW_ERRORS) System.err.println(">> EAN code too short: " + ean_code + ": " + pharma.getDscr()); } else if (ean_code.length() > 13) { if (SHOW_ERRORS) System.err.println(">> EAN code too long: " + ean_code + ": " + pharma.getDscr()); } } stopTime = System.currentTimeMillis(); if (SHOW_LOGS) System.out.println(pharma_list.size() + " medis in " + (stopTime - startTime) / 1000.0f + " sec"); // Load BAG xml file File bag_xml_file = new File(FILE_PREPARATIONS_XML); FileInputStream fis_bag = new FileInputStream(bag_xml_file); startTime = System.currentTimeMillis(); if (SHOW_LOGS) System.out.print("- Processing preparations xml ... "); context = JAXBContext.newInstance(Preparations.class); um = context.createUnmarshaller(); Preparations prepInfos = (Preparations) um.unmarshal(fis_bag); List<Preparations.Preparation> prep_list = prepInfos.getPreparations(); int num_preparations = 0; for (Preparations.Preparation prep : prep_list) { String swissmedicno5_str = prep.getSwissmedicNo5(); if (swissmedicno5_str != null) { String orggencode_str = ""; // "O", "G" or empty -> "" String flagSB20_str = ""; // "Y" -> 20% or "N" -> 10% if (prep.getOrgGenCode() != null) orggencode_str = prep.getOrgGenCode(); if (prep.getFlagSB20() != null) { flagSB20_str = prep.getFlagSB20(); if (flagSB20_str.equals("Y")) { if (DB_LANGUAGE.equals("de")) flagSB20_str = "SB 20%"; else if (DB_LANGUAGE.equals("fr")) flagSB20_str = "QP 20%"; } else if (flagSB20_str.equals("N")) { if (DB_LANGUAGE.equals("de")) flagSB20_str = "SB 10%"; else if (DB_LANGUAGE.equals("fr")) flagSB20_str = "QP 10%"; } else flagSB20_str = ""; } add_info_map.put(swissmedicno5_str, orggencode_str + ";" + flagSB20_str); } List<Preparation.Packs> packs_list = prep.getPacks(); for (Preparation.Packs packs : packs_list) { // Extract codes for therapeutic index / classification String bag_application = ""; String therapeutic_code = ""; List<Preparations.Preparation.ItCodes> itcode_list = prep.getItCodes(); for (Preparations.Preparation.ItCodes itc : itcode_list) { List<Preparations.Preparation.ItCodes.ItCode> code_list = itc.getItCode(); int index = 0; for (Preparations.Preparation.ItCodes.ItCode code : code_list) { if (index == 0) { if (DB_LANGUAGE.equals("de")) therapeutic_code = code.getDescriptionDe(); else if (DB_LANGUAGE.equals("fr")) therapeutic_code = code.getDescriptionFr(); } else { if (DB_LANGUAGE.equals("de")) bag_application = code.getDescriptionDe(); else if (DB_LANGUAGE.equals("fr")) bag_application = code.getDescriptionFr(); } index++; } } // Generate new package info List<Preparation.Packs.Pack> pack_list = packs.getPack(); for (Preparation.Packs.Pack pack : pack_list) { // Get SwissmedicNo8 and used it as a key to extract all the relevant package info String swissMedicNo8 = pack.getSwissmedicNo8(); ArrayList<String> pi_row = package_info.get(swissMedicNo8); // Preparation also in BAG xml file (we have a price) if (pi_row != null) { // Update Swissmedic catory if necessary ("N->A", Y->"A+") if (pack.getFlagNarcosis().equals("Y")) pi_row.set(5, pi_row.get(5) + "+"); // Extract point limitations List<Preparations.Preparation.Packs.Pack.PointLimitations> point_limits = pack .getPointLimitations(); for (Preparations.Preparation.Packs.Pack.PointLimitations limits : point_limits) { List<Preparations.Preparation.Packs.Pack.PointLimitations.PointLimitation> plimits_list = limits .getPointLimitation(); if (plimits_list.size() > 0) if (plimits_list.get(0) != null) pi_row.set(12, ", LIM" + plimits_list.get(0).getPoints() + ""); } // Extract exfactory and public prices List<Preparations.Preparation.Packs.Pack.Prices> price_list = pack.getPrices(); for (Preparations.Preparation.Packs.Pack.Prices price : price_list) { List<Preparations.Preparation.Packs.Pack.Prices.PublicPrice> public_price = price .getPublicPrice(); List<Preparations.Preparation.Packs.Pack.Prices.ExFactoryPrice> exfactory_price = price .getExFactoryPrice(); if (exfactory_price.size() > 0) { try { float f = Float.valueOf(exfactory_price.get(0).getPrice()); String ep = String.format("%.2f", f); pi_row.set(8, "CHF " + ep); } catch (NumberFormatException e) { if (SHOW_ERRORS) System.err.println("Number format exception (exfactory price): " + swissMedicNo8 + " (" + public_price.size() + ")"); } } if (public_price.size() > 0) { try { float f = Float.valueOf(public_price.get(0).getPrice()); String pp = String.format("%.2f", f); pi_row.set(7, "CHF " + pp); if (DB_LANGUAGE.equals("de")) pi_row.set(11, ", SL"); else if (DB_LANGUAGE.equals("fr")) pi_row.set(11, ", LS"); } catch (NumberFormatException e) { if (SHOW_ERRORS) System.err.println("Number format exception (public price): " + swissMedicNo8 + " (" + public_price.size() + ")"); } } // Add application area and therapeutic code if (!bag_application.isEmpty()) pi_row.set(6, pi_row.get(6) + bag_application + " (BAG)"); pi_row.set(9, therapeutic_code); } } } } num_preparations++; } stopTime = System.currentTimeMillis(); if (SHOW_LOGS) System.out.println( num_preparations + " preparations in " + (stopTime - startTime) / 1000.0f + " sec"); // Loop through all SwissmedicNo8 numbers for (Map.Entry<String, ArrayList<String>> entry : package_info.entrySet()) { String swissmedicno8 = entry.getKey(); ArrayList<String> pi_row = entry.getValue(); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (JAXBException e) { e.printStackTrace(); } }
From source file:imageClassify.TestForest.java
private void testFile(Path inPath, Path outPath, DataConverter converter, DecisionForest forest, Dataset dataset, Collection<double[]> results, Random rng) throws IOException { // create the predictions file FSDataOutputStream ofile = null;/*w w w . j a v a2s . co m*/ if (outPath != null) { ofile = outFS.create(outPath); } FSDataInputStream input = dataFS.open(inPath); try { Scanner scanner = new Scanner(input, "UTF-8"); while (scanner.hasNextLine()) { String line = scanner.nextLine(); if (line.isEmpty()) { continue; // skip empty lines } Instance instance = converter.convert(line); double prediction = forest.classify(dataset, rng, instance); if (ofile != null) { ofile.writeChars(Double.toString(prediction)); // write the prediction ofile.writeChar('\n'); } results.add(new double[] { dataset.getLabel(instance), prediction }); } scanner.close(); } finally { Closeables.close(input, true); } }
From source file:com.joliciel.jochre.search.JochreIndexBuilderImpl.java
private void updateDocumentInternal(File documentDir) { try {//from ww w . j a v a 2s. c o m LOG.info("Updating index for " + documentDir.getName()); File zipFile = new File(documentDir, documentDir.getName() + ".zip"); if (!zipFile.exists()) { LOG.info("Nothing to index in " + documentDir.getName()); return; } long zipDate = zipFile.lastModified(); this.deleteDocumentInternal(documentDir); File[] offsetFiles = documentDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith(".obj"); } }); for (File offsetFile : offsetFiles) { offsetFile.delete(); } int i = 0; Map<String, String> fields = new TreeMap<String, String>(); File metaDataFile = new File(documentDir, "metadata.txt"); Scanner scanner = new Scanner( new BufferedReader(new InputStreamReader(new FileInputStream(metaDataFile), "UTF-8"))); while (scanner.hasNextLine()) { String line = scanner.nextLine(); String key = line.substring(0, line.indexOf('\t')); String value = line.substring(line.indexOf('\t')); fields.put(key, value); } scanner.close(); JochreXmlDocument xmlDoc = this.searchService.newDocument(); JochreXmlReader reader = this.searchService.getJochreXmlReader(xmlDoc); ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile)); ZipEntry ze = null; while ((ze = zis.getNextEntry()) != null) { LOG.debug("Adding zipEntry " + i + ": " + ze.getName()); String baseName = ze.getName().substring(0, ze.getName().lastIndexOf('.')); UnclosableInputStream uis = new UnclosableInputStream(zis); reader.parseFile(uis, baseName); i++; } zis.close(); i = 0; StringBuilder sb = new StringBuilder(); coordinateStorage = searchService.getCoordinateStorage(); offsetLetterMap = new HashMap<Integer, JochreXmlLetter>(); int startPage = -1; int endPage = -1; int docCount = 0; int wordCount = 0; int cumulWordCount = 0; for (JochreXmlImage image : xmlDoc.getImages()) { if (startPage < 0) startPage = image.getPageIndex(); endPage = image.getPageIndex(); int remainingWords = xmlDoc.wordCount() - (cumulWordCount + wordCount); LOG.debug("Word count: " + wordCount + ", cumul word count: " + cumulWordCount + ", total xml words: " + xmlDoc.wordCount() + ", remaining words: " + remainingWords); if (wordsPerDoc > 0 && wordCount >= wordsPerDoc && remainingWords >= wordsPerDoc) { LOG.debug("Creating new index doc: " + docCount); JochreIndexDocument indexDoc = searchService.newJochreIndexDocument(documentDir, docCount, sb, coordinateStorage, startPage, endPage, fields); indexDoc.save(indexWriter); docCount++; sb = new StringBuilder(); coordinateStorage = searchService.getCoordinateStorage(); startPage = image.getPageIndex(); offsetLetterMap = new HashMap<Integer, JochreXmlLetter>(); cumulWordCount += wordCount; wordCount = 0; } LOG.debug("Processing page: " + image.getFileNameBase()); File imageFile = null; for (String imageExtension : imageExtensions) { imageFile = new File(documentDir, image.getFileNameBase() + "." + imageExtension); if (imageFile.exists()) break; imageFile = null; } if (imageFile == null) throw new RuntimeException("No image found in directory " + documentDir.getAbsolutePath() + ", baseName " + image.getFileNameBase()); coordinateStorage.addImage(sb.length(), imageFile.getName(), image.getPageIndex()); for (JochreXmlParagraph par : image.getParagraphs()) { coordinateStorage.addParagraph(sb.length(), new Rectangle(par.getLeft(), par.getTop(), par.getRight(), par.getBottom())); for (JochreXmlRow row : par.getRows()) { coordinateStorage.addRow(sb.length(), new Rectangle(row.getLeft(), row.getTop(), row.getRight(), row.getBottom())); int k = 0; for (JochreXmlWord word : row.getWords()) { wordCount++; for (JochreXmlLetter letter : word.getLetters()) { offsetLetterMap.put(sb.length(), letter); if (letter.getText().length() > 1) { for (int j = 1; j < letter.getText().length(); j++) { offsetLetterMap.put(sb.length() + j, letter); } } sb.append(letter.getText()); } k++; boolean finalDash = false; if (k == row.getWords().size() && word.getText().endsWith("-") && word.getText().length() > 1) finalDash = true; if (!finalDash) sb.append(" "); } } sb.append("\n"); } i++; } JochreIndexDocument indexDoc = searchService.newJochreIndexDocument(documentDir, docCount, sb, coordinateStorage, startPage, endPage, fields); indexDoc.save(indexWriter); File lastIndexDateFile = new File(documentDir, "indexDate.txt"); Writer writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(lastIndexDateFile, false), "UTF8")); writer.write("" + zipDate); writer.flush(); writer.close(); } catch (IOException ioe) { LogUtils.logError(LOG, ioe); throw new RuntimeException(ioe); } }
From source file:com.cisco.dbds.utils.tims.TIMS.java
/** * Readhtmlfile pass./*from w w w.java2 s . c om*/ * * @return the array list * @throws FileNotFoundException the file not found exception */ public static ArrayList<String> readhtmlfilePass() throws FileNotFoundException { ArrayList<String> re = new ArrayList<String>(); String fEncoding = "UTF-8"; String tt = ""; int fcount = 0; Scanner scanner = new Scanner(new FileInputStream(fFileName), fEncoding); try { while (scanner.hasNextLine()) { tt = scanner.nextLine(); tt = tt.trim(); if (tt.contains("Failed Test Case ID")) fcount = 1; if (fcount == 0 && tt.contains("Ttv") && !(tt.contains("Precheck")) && !(tt.contains("Precondition"))) { System.out.println("LINE read: " + tt); String a[] = tt.split("<td>"); System.out.println("tcid: " + a[3].substring(a[3].indexOf('T'), 19)); System.out.println("Desc: " + a[5].substring(0, a[5].indexOf("<"))); System.out.println("status: " + a[6].substring(a[6].indexOf(">") + 1, a[6].indexOf("d") + 1)); String aa = a[3].substring(a[3].indexOf('T'), 19) + "~" + a[5].substring(0, a[5].indexOf("<")) + "~" + a[6].substring(a[6].indexOf(">") + 1, a[6].indexOf("d") + 1); re.add(aa); } } } finally { scanner.close(); } return re; }