List of usage examples for java.io FileNotFoundException printStackTrace
public void printStackTrace()
From source file:org.aliuge.crawler.fetcher.Fetcher.java
private static void storeProxyIp() { // ? ???ip//from w w w. j a v a2 s.c o m Properties pro = new Properties(); for (int i = 0; i < proxyIps.size(); i++) { pro.setProperty("proxy" + i, proxyIps.get(i)); } OutputStream out = null; try { out = new FileOutputStream(new File(config.getProxyPath())); pro.store(out, "?Ip,[" + DateTimeUtil.getDateTime() + "]"); } catch (FileNotFoundException e) { slog.error("?IP????:" + new File(config.getProxyPath()).toString(), e); e.printStackTrace(); } catch (IOException e) { slog.error("?Ip:", e); e.printStackTrace(); } finally { try { out.close(); } catch (IOException e) { } } }
From source file:co.raveesh.yspages.YSScraper.java
/** * This function writes a JSONObject to the required output file * @param fileName Output file name. The /output directory and .json extension are added by this method * @param object The required output content in JSONObject form *//*from w w w . j a v a 2 s.c o m*/ private static void writeToFile(String fileName, JSONObject object) { PrintWriter writer = null; try { writer = new PrintWriter(Constants.OUTPUT_BASE + fileName + ".json", "UTF-8"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } writer.println(object.toString()); writer.close(); }
From source file:main.java.refinement_class.Useful.java
public static KieSession build(String s1, String s2) throws Exception { KieServices kieServices = KieServices.Factory.get(); kieServices.newKieClasspathContainer(H2mserviceImpl.class.getClassLoader()); KieFileSystem kfs = kieServices.newKieFileSystem(); Thread.currentThread().setContextClassLoader(H2mserviceImpl.class.getClassLoader()); try {//www. j a v a2 s . c o m URL url = getUrl(H2mserviceImpl.class, s1); kfs.write(s2, kieServices.getResources().newInputStreamResource(url.openStream())); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } KieBuilder kieBuilder = kieServices.newKieBuilder(kfs).buildAll(); Results results = kieBuilder.getResults(); if (results.hasMessages(Message.Level.ERROR)) { System.out.println(results.getMessages()); throw new IllegalStateException("### errors ###"); } KieContainer kieContainer = kieServices.newKieContainer(kieServices.getRepository().getDefaultReleaseId()); KieBase kieBase = kieContainer.getKieBase(); KieSession ksession = kieContainer.newKieSession(); return ksession; }
From source file:org.frameworkset.spi.remote.http.Client.java
public static String getFileContent(InputStream reader, String charSet) throws IOException { ByteArrayOutputStream swriter = null; OutputStream temp = null;/* ww w . ja v a 2 s .co m*/ try { // reader = new FileInputStream(file); swriter = new ByteArrayOutputStream(); temp = new BufferedOutputStream(swriter); int len = 0; byte[] buffer = new byte[1024]; while ((len = reader.read(buffer)) > 0) { temp.write(buffer, 0, len); } temp.flush(); if (charSet != null && !charSet.equals("")) return swriter.toString(charSet); else return swriter.toString(); } catch (FileNotFoundException e) { e.printStackTrace(); return ""; } catch (IOException e) { e.printStackTrace(); throw e; } finally { if (reader != null) try { reader.close(); } catch (IOException e) { } if (swriter != null) try { swriter.close(); } catch (IOException e) { } if (temp != null) try { temp.close(); } catch (IOException e) { } } }
From source file:Query8Servlet.java
public static Map<String, List<Double>> getTestCaseInformation() { List<String> patientNames = new ArrayList<String>(); Map<String, List<Double>> testPatientToExprValues = new HashMap<String, List<Double>>(); List<Double> exprValues = null; BufferedReader reader = null; String line = null;//from w w w. ja v a 2 s. c o m String[] parts = null; try { reader = new BufferedReader( new FileReader("C://Users//Vivekanandh//Desktop//Data Mining//Data Files//test_samples.txt")); line = reader.readLine().trim(); parts = line.split("\\s"); //Adding the patient names to the list for (String patientName : parts) { patientNames.add(patientName); } while ((line = reader.readLine()) != null) { parts = line.split("\\s"); int geneID = Integer.parseInt(parts[0]); //Adding the expression values only from the informative genes if (GeneConstants.informativeGenes.contains(geneID)) { //Iterating through the expression values for different patients to add them to the map for (int j = 0; j < patientNames.size(); j++) { if (testPatientToExprValues.containsKey(patientNames.get(j))) exprValues = testPatientToExprValues.get(patientNames.get(j)); else exprValues = new ArrayList<Double>(); exprValues.add(Double.parseDouble(parts[j + 1])); testPatientToExprValues.put(patientNames.get(j), exprValues); } } } reader.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return testPatientToExprValues; }
From source file:exm.stc.ui.Main.java
private static OutputStream openForOutput(File outfile) { try {/*from w w w .ja v a2 s . co m*/ FileOutputStream stream = new FileOutputStream(outfile); return new BufferedOutputStream(stream); } catch (FileNotFoundException e) { e.printStackTrace(); System.err.println("Unexpected error opening " + outfile.getAbsolutePath() + " for output."); System.exit(1); return null; } }
From source file:com.mvdb.etl.actions.ActionUtils.java
public static void zipFullDirectory(String sourceDir, String targetZipFile) { FileOutputStream fos = null;/*from ww w. j a va 2 s . c om*/ BufferedOutputStream bos = null; ZipOutputStream zos = null; try { fos = new FileOutputStream(targetZipFile); bos = new BufferedOutputStream(fos); zos = new ZipOutputStream(bos); zipDir(sourceDir, new File(sourceDir), zos); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (zos != null) { try { zos.flush(); zos.close(); } catch (IOException e) { e.printStackTrace(); } } if (bos != null) { try { bos.flush(); bos.close(); } catch (IOException e) { e.printStackTrace(); } } if (fos != null) { try { fos.flush(); fos.close(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:eu.irreality.age.SwingAetheriaGameLoaderInterface.java
public static void redirectStandardError(String file) { File f = new File(file); if (!f.exists()) { if (!f.getParentFile().exists()) { if (!f.getParentFile().mkdirs()) { System.err.println( "Could not redirect standard error to " + file + ": unable to create directories."); return; }//w w w. j a v a 2s .c om } } //{f.getParentFile().exists() try { System.setErr(new PrintStream(new FileOutputStream(f, true))); System.err.println("[" + new Date() + "]"); } catch (FileNotFoundException e) { System.err.println("Could not redirect standard error to " + file + ":"); e.printStackTrace(); } }
From source file:co.raveesh.yspages.YSScraper.java
private static String returnFileContents(String fileName) { try {/*from ww w. ja v a 2s . c o m*/ String sCurrentLine, fileData = ""; try { BufferedReader br = new BufferedReader(new FileReader(fileName)); while ((sCurrentLine = br.readLine()) != null) { fileData = sCurrentLine + "\n"; } } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } fileData = fileData.trim(); return fileData; } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:in.bbat.license.LicenseManager.java
public static LicenseInfo getCurrentLicense() { Properties p = new Properties(); try {/*from ww w. j a v a 2s . c om*/ p.load(new FileInputStream(new File( "/home/syed/.littleeye/workspace/.metadata/.plugins/com.littleeyelabs.utils/littleeye.properties"))); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } String str = p.getProperty("license.activation.enc"); LicenseInfo localLicenseInfo = parseLicenseEncrypted(str); if (localLicenseInfo != null) return localLicenseInfo; str = System.getProperty("license.activation"); localLicenseInfo = parseLicenseBase64(str); if (localLicenseInfo != null) return localLicenseInfo; localLicenseInfo = parseLicenseEncrypted(str); if (localLicenseInfo != null) return localLicenseInfo; return null; }