List of usage examples for java.io FileNotFoundException printStackTrace
public void printStackTrace()
From source file:tools.EpsServletUtilities.java
public static String saveChartAsEPS(JFreeChart chart, int width, int height, HttpSession session) throws IOException { if (chart == null) { throw new IllegalArgumentException("Null 'chart' argument."); }// ww w . ja va2 s .c o m EpsServletUtilities.createTempDir(); String prefix = EpsServletUtilities.tempFilePrefix; if (session == null) { prefix = EpsServletUtilities.tempOneTimeFilePrefix; } File tempFile = File.createTempFile(prefix, ".eps", new File(System.getProperty("java.io.tmpdir"))); EpsGraphics2D graphic2d = new EpsGraphics2D(); chart.draw(graphic2d, new Rectangle2D.Double(0, 0, width, height)); try { FileWriter fos = new FileWriter(tempFile); fos.write(graphic2d.toString()); fos.close(); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e2) { e2.printStackTrace(); } if (session != null) { EpsServletUtilities.registerChartForDeletion(tempFile, session); } return tempFile.getPath(); }
From source file:com.cats.version.utils.Utils.java
public static void copyFile(File srcFile, File destFile) { FileInputStream fis = null;//from w w w. j a v a2s . c o m FileOutputStream fos = null; try { fis = new FileInputStream(srcFile); fos = new FileOutputStream(destFile); FileChannel inChannel = fis.getChannel(); FileChannel outChannel = fos.getChannel(); inChannel.transferTo(0, inChannel.size(), outChannel); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { Utils.closeRes(fis); Utils.closeRes(fos); } }
From source file:com.yojiokisoft.yumekanow.exception.MyUncaughtExceptionHandler.java
/** * ??????.// w w w. ja va 2 s . co m * * @param activity ??Activity????? * @param ex */ public static void sendBugReport(Activity activity, Throwable ex) { try { MyLog.writeStackTrace(MyConst.getCaughtBugFilePath(), ex); } catch (FileNotFoundException e) { e.printStackTrace(); } sBugReportFile = new File(MyConst.getCaughtBugFilePath()); if (sBugReportFile == null || !sBugReportFile.exists()) { return; } setVersionName(); MyDialog.Builder.newInstance(activity).setTitle(activity.getString(R.string.err_dialog_title)) .setMessage(activity.getString(R.string.err_dialog_msg2)) .setPositiveLabel(activity.getString(R.string.send)).setPositiveClickListener(mBugDialogOkClicked) .setNegativeLabel(activity.getString(R.string.cancel)) .setNegativeClickListener(mBugDialogCancelClicked).show(); }
From source file:com.oculusinfo.ml.spark.unsupervised.TestDPMeans.java
public static void genTestData(int k) { PrintWriter writer;//w w w. ja va 2s.co m try { writer = new PrintWriter("test.txt", "UTF-8"); // each class size is equal int classSize = 1000000 / k; double stdDev = 30.0; // generate k classes of data points using a normal distribution with random means and fixed std deviation for (int i = 0; i < k; i++) { Random rnd = new Random(); double meanLat = rnd.nextDouble() * 400.0; double meanLon = rnd.nextDouble() * 400.0; // randomly generate a dataset of lat, lon points for (int j = 0; j < classSize; j++) { double x = rnd.nextGaussian() * stdDev + meanLat; double y = rnd.nextGaussian() * stdDev + meanLon; writer.println(x + "," + y); } } writer.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.yojiokisoft.japanesecalc.MyUncaughtExceptionHandler.java
/** * ??????.//from w w w . j a v a2 s . c o m * * @param activityContext ??Activity?Context????? * @param ex */ public static void sendBugReport(Context activityContext, Throwable ex) { try { MyLog.writeStackTrace(MyConst.getCaughtBugFilePath(), ex); } catch (FileNotFoundException e) { e.printStackTrace(); } sBugReportFile = new File(MyConst.getCaughtBugFilePath()); if (sBugReportFile == null || !sBugReportFile.exists()) { return; } setVersionName(); MyDialog.Builder.newInstance(activityContext).setTitle(activityContext.getString(R.string.err_dialog_title)) .setMessage(activityContext.getString(R.string.err_dialog_msg2)) .setPositiveLabel(activityContext.getString(R.string.send)) .setPositiveClickListener(mBugDialogOkClicked) .setNegativeLabel(activityContext.getString(R.string.cancel)) .setNegativeClickListener(mBugDialogCancelClicked).show(); }
From source file:de.tudarmstadt.ukp.wikipedia.util.StringUtils.java
public static String getFileContent(String filename, String encoding) { File file = new File(filename); InputStream is;/*from w w w . ja v a 2s. co m*/ String textContents = ""; try { is = new FileInputStream(file); // as the whole file is read at once -> buffering not necessary // InputStream is = new BufferedInputStream(new FileInputStream(file)); byte[] contents = new byte[(int) file.length()]; is.read(contents); textContents = new String(contents, encoding); } catch (FileNotFoundException e) { logger.error("File " + file.getAbsolutePath() + " not found."); e.printStackTrace(); } catch (IOException e) { logger.error("IO exception while reading file " + file.getAbsolutePath()); e.printStackTrace(); } return textContents; }
From source file:com.nts.alphamale.data.Settings.java
public static void loadSettings() { if (new File(SETTINGS).exists()) { Properties prop = new Properties(); try {/*from w w w . ja v a 2 s. c o m*/ prop.load(new FileReader(SETTINGS)); if (prop.getProperty("command_timeout") != null) EXECUTOR_TIMEOUT = Long.parseLong(prop.getProperty("command_timeout")); if (prop.getProperty("double_tap_threshold") != null) DOUBLE_TAP_THRESHOLD = Double.parseDouble(prop.getProperty("double_tap_threshold")); if (prop.getProperty("long_tap_threshold") != null) LONG_TAP_THRESHOLD = Double.parseDouble(prop.getProperty("long_tap_threshold")); if (prop.getProperty("swipe_area_threshold") != null) SWIPE_AREA_THRESHOLD = Integer.parseInt(prop.getProperty("swipe_area_threshold")); if (prop.getProperty("swipe_angle_threshold") != null) SWIPE_ANGLE_THRESHOLD = Integer.parseInt(prop.getProperty("swipe_angle_threshold")); if (prop.getProperty("find_timeout") != null) FIND_ELEMENT_TIMEOUT = Long.parseLong(prop.getProperty("find_timeout")); if (prop.getProperty("idle_timeout") != null) WAIT_FOR_IDLE_TIMEOUT = Integer.parseInt(prop.getProperty("idle_timeout")); if (prop.getProperty("orientation_schedule") != null) ORIENTATION_SCHEDULE = Long.parseLong(prop.getProperty("orientation_schedule")); if (prop.getProperty("keypad_schedule") != null) KEYPAD_SCHEDULE = Long.parseLong(prop.getProperty("keypad_schedule")); if (prop.getProperty("event_interval") != null) EVENT_INTERVAL = Integer.parseInt(prop.getProperty("event_interval")); if (prop.getProperty("touchscreen_device") != null) TOUCH_DEVICE = prop.getProperty("touchscreen_device"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else { FileWriterWithEncoding fw = null; String lineSeparator = System.getProperty("line.separator"); try { fw = new FileWriterWithEncoding(SETTINGS, "UTF-8"); fw.write("# command timeout(ms)" + lineSeparator); fw.write("command_timeout = 5000" + lineSeparator); fw.write(lineSeparator); fw.write("# double tap threshold(sec)" + lineSeparator); fw.write("double_tap_threshold = 0.7" + lineSeparator); fw.write(lineSeparator); fw.write("# long tap threshold(sec)" + lineSeparator); fw.write("long_tap_threshold = 0.7" + lineSeparator); fw.write(lineSeparator); fw.write("# swipe area threshold(px)" + lineSeparator); fw.write("swipe_area_threshold = 100" + lineSeparator); fw.write(lineSeparator); fw.write("# swipe angle threshold" + lineSeparator); fw.write("swipe_angle_threshold = 45" + lineSeparator); fw.write(lineSeparator); fw.write("# find element threshold(ms)" + lineSeparator); fw.write("find_timeout = 2000" + lineSeparator); fw.write(lineSeparator); fw.write("# idle threshold(ms)" + lineSeparator); fw.write("idle_timeout = 2000" + lineSeparator); fw.write(lineSeparator); fw.write("# orientation recognition schedule" + lineSeparator); fw.write("orientation_schedule = 500" + lineSeparator); fw.write(lineSeparator); fw.write("# keypad recognition schedule" + lineSeparator); fw.write("keypad_schedule = 500" + lineSeparator); fw.write(lineSeparator); fw.write("# follower event injection interval(ms)" + lineSeparator); fw.write("event_interval = 500" + lineSeparator); fw.write(lineSeparator); fw.write("# touch screen device" + lineSeparator); fw.write( "touchscreen_device = _touchscreen,touch_dev,clearpad,sensor00,atmel_mxt_540s,synaptics_rmi,mtk-tpd"); } catch (IOException e) { e.printStackTrace(); } finally { try { fw.close(); } catch (IOException e) { } } } }
From source file:com.siemens.scr.avt.ad.io.DicomIO.java
public static int saveOrUpdateDicomFromFile(Class<?> clazz, String filePath) { try {//from w w w . j a va 2 s.com return saveOrUpdateDicomFromStream( new FileInputStream(Config.getConfig().getAdDicomStore() + File.separator + filePath)); } catch (FileNotFoundException e) { e.printStackTrace(); } return 0; }
From source file:com.seleniumtests.util.helper.AppTestDocumentation.java
private static void explorePages(File srcDir) throws IOException { Files.walk(Paths.get(srcDir.getAbsolutePath())).filter(Files::isRegularFile) .filter(p -> p.getFileName().toString().endsWith(".java")).forEach(t -> { try { parseWebPage(t);/*from w w w . j ava2 s. c om*/ } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }); }
From source file:com.seleniumtests.util.helper.AppTestDocumentation.java
private static void exploreTests(File srcDir) throws IOException { Files.walk(Paths.get(srcDir.getAbsolutePath())).filter(Files::isRegularFile) .filter(p -> p.getFileName().toString().endsWith(".java")).forEach(t -> { try { parseTest(t);// w w w . j a v a2s . c o m } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } }); }