List of usage examples for java.io FileNotFoundException printStackTrace
public void printStackTrace()
From source file:com.sarm.Travelogue.process.DestinationProcessorTest.java
@BeforeClass public static void setUpClass() { logger.info("DestinationProcessorTest Commencing loading test properties ..."); Properties prop = new Properties(); String propFileName = LonelyConstants.testPropertyFile; try (InputStream input = new FileInputStream(propFileName)) { if (input == null) { logger.debug("input Stream for test.properties file : is Null "); throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath"); }/* ww w.j a va 2 s . c om*/ logger.debug("Loading properties file " + propFileName); prop.load(input); } catch (FileNotFoundException ex) { logger.debug("FileNotFoundException " + propFileName); ex.printStackTrace(); } catch (IOException ex) { logger.debug("IOException " + propFileName); ex.printStackTrace(); } taxonomyFileName = prop.getProperty(LonelyConstants.propertyTaxonomy); targetLocation = prop.getProperty(LonelyConstants.propertyHtmlTarget); destinationFileName = prop.getProperty(LonelyConstants.propertyDestination); destinationsConcurrantlyExpresult = prop.getProperty(LonelyConstants.destinationsConcurrantlyExpresult); numOfDestinations = Integer.valueOf(prop.getProperty(LonelyConstants.numOfDestinations)); regressDestinationfile = prop.getProperty(LonelyConstants.regressDestinationfile); indexOfdestInConcurrent = prop.getProperty(LonelyConstants.indexOfdestInConcurrent); try { sampleTesttaxonomies = TaxonomyProcessor.processTaxonomy(taxonomyFileName); } catch (FileNotFoundException ex) { logger.debug("FileNotFoundException on file : " + taxonomyFileName); ex.printStackTrace(); } catch (JAXBException ex) { logger.debug("JAXBException : "); ex.printStackTrace(); } }
From source file:com.siemens.scr.avt.ad.io.DicomIO.java
private static int updateAtLevelSavingOnParent(byte updateLevel, Object parent, DicomObject dcm, Session session) {//from ww w.j a va2 s .co m DicomOutputStream output; File file = null; try { file = new File(Config.getConfig().getAdDicomStore() + File.separator + dcm.getString(0x00080018)); output = new DicomOutputStream(new FileOutputStream(file)); output.writeDicomFile(dcm); } catch (FileNotFoundException e) { e.printStackTrace(); return -1; } catch (IOException e) { e.printStackTrace(); return -1; } switch (updateLevel) { case STUDY: Patient patient = (Patient) parent; GeneralStudy newStudy = DicomFactory.getInstance().createStudy(dcm, file.getAbsolutePath()); patient.addStudy(newStudy); HibernateUtil.saveOrUpdate(patient, session); return newStudy.getPK_ID(); case SERIES: GeneralStudy study = (GeneralStudy) parent; GeneralSeries newSeries = DicomFactory.getInstance().createSeries(dcm, file.getAbsolutePath()); study.addSeries(newSeries); HibernateUtil.saveOrUpdate(study, session); return newSeries.getPK_ID(); case IMAGE: GeneralSeries series = (GeneralSeries) parent; GeneralImage image = DicomFactory.getInstance().createImage(dcm, file.getAbsolutePath()); series.addImage(image); HibernateUtil.saveOrUpdate(series, session); return image.getPK_ID(); default: case PATIENT: Patient newPatient = DicomFactory.getInstance().createPatient(dcm, file.getAbsolutePath()); HibernateUtil.save(newPatient, session); return newPatient.getPK_ID(); case NONE: return -1; } }
From source file:edu.ku.brc.specify.tools.FixMetaTags.java
static public String getContents(File aFile) { //...checks on aFile are elided StringBuffer contents = new StringBuffer(); //System.out.println(aFile.getName()); //declared here only to make visible to finally clause BufferedReader input = null;/*from ww w . ja v a2s.c om*/ try { String eol = System.getProperty("line.separator"); System.out.println("\n" + aFile.getName()); //use buffering //this implementation reads one line at a time //FileReader always assumes default encoding is OK! input = new BufferedReader(new FileReader(aFile)); String line = null; //not declared within while loop //boolean doIt = false; int cnt = 0; boolean doComment = true; boolean doClassDesc = true; while ((line = input.readLine()) != null) { cnt++; boolean addLine = true; if (doComment) { int inx = line.indexOf("<!--"); if (inx > -1) { do { line = input.readLine(); cnt++; } while (line.indexOf("-->") == -1); doComment = false; continue; } } if (doComment && line.indexOf("<class") > -1) { doComment = false; } if (doClassDesc) { int inx = line.indexOf("class-description"); if (inx > -1) { do { line = input.readLine(); cnt++; } while (line.indexOf("</meta>") == -1); contents.append(" <meta attribute=\"class-description\" inherit=\"false\"/>"); contents.append(eol); doClassDesc = false; continue; } } int ccInx = line.indexOf("class-code"); int inx = line.indexOf("<meta"); if (inx > -1 && ccInx == -1) { inx = line.indexOf("</meta>"); if (inx == -1) { String textLine = input.readLine(); cnt++; String endTag = null; if (textLine.indexOf("</meta>") == -1) { endTag = input.readLine(); cnt++; } if (endTag != null && endTag.indexOf("</meta>") == -1) { throw new RuntimeException("Assumption bad about end tab. line " + cnt); } contents.append(StringUtils.stripEnd(line, " ")); contents.append(StringUtils.strip(textLine)); if (endTag != null) { contents.append(StringUtils.strip(endTag)); } contents.append(eol); addLine = false; } } if (addLine) { contents.append(line); contents.append(System.getProperty("line.separator")); } } } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } finally { try { if (input != null) { //flush and close both "input" and its underlying FileReader input.close(); } } catch (IOException ex) { ex.printStackTrace(); } } return contents.toString(); }
From source file:cn.mdict.utils.IOUtil.java
public static boolean httpGetFile(String url, String target, StatusReport statusReport) { try {//from w w w . j ava 2 s.co m OutputStream os = new FileOutputStream(target); return httpGetFile(url, os, statusReport); } catch (FileNotFoundException e) { e.printStackTrace(); } return false; }
From source file:com.nokia.carbide.internal.bugreport.model.Communication.java
/** * Sends given fields as a bug_report to the server provided by product. * @param fields values which are sent to the server * @param product product provides e.g. server URL * @return bug_id of the added bug_entry * @throws RuntimeException if an error occurred. Error can be either some communication error * or error message provided by the server (e.g. invalid password) *///from w w w.j a va 2 s. c o m public static String sendBugReport(Hashtable<String, String> fields, IProduct product) throws RuntimeException { // Nothing to send if (fields == null || fields.size() < 1) { throw new RuntimeException(Messages.getString("Communication.NothingToSend")); //$NON-NLS-1$ } String bugNumber = ""; //$NON-NLS-1$ String url = product.getUrl(); if (url.startsWith("https")) { //$NON-NLS-1$ // we'll support HTTPS with trusted (i.e. signed) certificates // Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); //$NON-NLS-1$ //$NON-NLS-2$ } PostMethod filePost = new PostMethod(url); Part[] parts = new Part[fields.size()]; int i = 0; Iterator<Map.Entry<String, String>> it = fields.entrySet().iterator(); // create parts while (it.hasNext()) { Map.Entry<String, String> productField = it.next(); // attachment field if (productField.getKey() == FieldsHandler.FIELD_ATTACHMENT) { File f = new File(productField.getValue()); try { parts[i] = new FilePart(FieldsHandler.FIELD_DATA, f); } catch (FileNotFoundException e) { e.printStackTrace(); parts[i] = new StringPart(FieldsHandler.FIELD_DATA, Messages.getString("Communication.NotFound")); //$NON-NLS-1$ } // string field } else { parts[i] = new StringPart(productField.getKey(), productField.getValue()); } i++; } filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams())); HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().setConnectionTimeout(8000); setProxyData(client, filePost); int status = 0; String receivedData = ""; //$NON-NLS-1$ try { status = client.executeMethod(filePost); receivedData = filePost.getResponseBodyAsString(1024 * 1024); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException(e); } finally { filePost.releaseConnection(); } // HTTP status codes: 2xx = Success if (status >= 200 && status < 300) { // some error occurred in the server side (e.g. invalid password) if (receivedData.contains(FieldsHandler.TAG_RESPONSE_ERROR) && receivedData.contains(FieldsHandler.TAG_RESPONSE_ERROR_CLOSE)) { int beginIndex = receivedData.indexOf(FieldsHandler.TAG_RESPONSE_ERROR) + FieldsHandler.TAG_RESPONSE_ERROR.length(); int endIndex = receivedData.indexOf(FieldsHandler.TAG_RESPONSE_ERROR_CLOSE); String error = receivedData.substring(beginIndex, endIndex); error = error.trim(); throw new RuntimeException(error); // bug_entry was added successfully to database, read the bug_number } else if (receivedData.contains(FieldsHandler.TAG_RESPONSE_BUG_ID) && receivedData.contains(FieldsHandler.TAG_RESPONSE_BUG_ID_CLOSE)) { int beginIndex = receivedData.indexOf(FieldsHandler.TAG_RESPONSE_BUG_ID) + FieldsHandler.TAG_RESPONSE_BUG_ID.length(); int endIndex = receivedData.indexOf(FieldsHandler.TAG_RESPONSE_BUG_ID_CLOSE); bugNumber = receivedData.substring(beginIndex, endIndex); bugNumber = bugNumber.trim(); // some unknown error } else { throw new RuntimeException(Messages.getString("Communication.UnknownError")); //$NON-NLS-1$ } // some HTTP error (status code other than 2xx) } else { String error = Messages.getString("Communication.HttpError") + status; //$NON-NLS-1$ throw new RuntimeException(error); } return bugNumber; }
From source file:fr.eo.util.dumper.Dumper.java
private static int getDumpLinesNumber() { File assertDir = new File(assetFolder); String[] dumpFileNames = assertDir.list(new FilenameFilter() { @Override// w w w . jav a 2 s . co m public boolean accept(File dir, String name) { return name.startsWith("dump") && name.endsWith(".sql"); } }); int nbDumpLines = 0; BufferedReader reader = null; try { for (String name : dumpFileNames) { reader = new BufferedReader(new InputStreamReader(new FileInputStream(assetFolder + name))); String currentLine = null; while ((currentLine = reader.readLine()) != null) { currentLine = currentLine.trim(); if (currentLine.length() != 0 && !currentLine.startsWith("--")) { nbDumpLines++; } } } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { e.printStackTrace(); } } } return nbDumpLines; }
From source file:cn.mdict.utils.IOUtil.java
public static boolean streamToFile(InputStream is, String fileName, boolean overwrite, StatusReport statusReport) {/*from ww w . jav a2 s. c om*/ // Check if the dest exists before copying File file = new File(fileName); if (file.exists() && !overwrite) return true; try { OutputStream os = new FileOutputStream(fileName); return streamDuplicate(is, os, statusReport); } catch (FileNotFoundException e) { e.printStackTrace(); } return false; }
From source file:com.google.api.ads.adwords.jaxws.extensions.kratu.KratuMain.java
/** * Prints the sample properties file on the default output. *//* www. jav a 2 s. c om*/ private static void printSamplePropertiesFile() { System.out.println("\n File: kratubackend-sample.properties example"); ClassPathResource sampleFile = new ClassPathResource(CLASSPATH_AW_REPORT_MODEL_PROPERTIES_LOCATION); Scanner fileScanner = null; try { fileScanner = new Scanner(sampleFile.getInputStream()); while (fileScanner.hasNext()) { System.out.println(fileScanner.nextLine()); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (fileScanner != null) { fileScanner.close(); } } }
From source file:musite.MusiteInit.java
public static void initializeModels() { PredictionModelManager manager = Musite.getModelManager(); manager.clear();//from www . ja v a 2s . c o m File modelDirFile = new File(MODEL_DIR); for (File file : modelDirFile.listFiles()) { if (file.isFile()) { String dir = file.getAbsolutePath(); if (!dir.endsWith("." + MODEL_APPEDIX)) continue; try { manager.addModelFile(file.getPath()); } catch (java.io.FileNotFoundException e) { e.printStackTrace(); } // try { // System.out.println(file.getAbsolutePath()); // java.util.List<musite.prediction.PredictionModel> model = // new java.util.ArrayList(manager.loadModels(file.getAbsolutePath())); // for (musite.prediction.PredictionModel m : model) { // // } // musite.util.IOUtil.serializeObject(model, file.getAbsolutePath(), "gz"); // } catch (Exception e) { // e.printStackTrace(); // } } } }
From source file:com.pieframework.runtime.core.Installer.java
public static void createConfigFile(Properties prop) { try {//w ww . j a v a 2s .co m File pieConfig = new File(prop.getProperty("pie.config")); //Backup the config file if it exists if (pieConfig.exists()) { File backup = new File(pieConfig.getPath() + "." + TimeUtils.getCurrentTimeStamp()); FileUtils.copyFile(pieConfig, backup); } //Create/Overwrite the config file OutputStream out = new FileOutputStream(pieConfig); prop.store(out, getComments()); System.out.println("Created config file: " + pieConfig.getPath()); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }