List of usage examples for java.io FileNotFoundException printStackTrace
public void printStackTrace()
From source file:net.dfs.server.main.ServerServicesStarter.java
public static void readProperties() { try {/*from w w w .j a v a2 s .co m*/ props.load(new FileInputStream("server.properties")); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static String readTextContent(String filePath) { BufferedReader reader = null; try {/* www .ja v a2 s . c om*/ reader = new BufferedReader(new FileReader(filePath)); StringBuilder sb = new StringBuilder(); while (reader.ready()) sb.append(reader.readLine()); return sb.toString(); } catch (FileNotFoundException e) { // e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { e.printStackTrace(); } } } return null; }
From source file:org.gtri.fhir.api.vistaex.rest.service.util.VistaUtil.java
public static Properties getProperties() { Properties properties = null; try {//from w ww. j ava 2s.co m InputStream fis = getFileInputStreamFromClassPath(PROPERTIES_FILE); properties = new Properties(); properties.load(fis); } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); properties = null; } catch (IOException ioe) { ioe.printStackTrace(); properties = null; } return properties; }
From source file:Main.java
/** * get the FileOutputStream// ww w .j a va 2 s . c om * @param filePath the filePath must contain head "/" * @return */ public static FileOutputStream getFileOutputStream(String filePath) { FileOutputStream fouts = null; File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + filePath.trim()); if (file.exists() && file.isFile()) { try { fouts = new FileOutputStream(file); Log.d("Ragnarok", "get the fouts path = " + file.getAbsolutePath()); return fouts; } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { try { File fileDirs = new File(file.getParent()); fileDirs.mkdirs(); //Log.d(LOG_TAG, "make the fileDirs " + fileDirs.getPath()); //file.createNewFile(); //Log.d("Ragnarok", "create a new file name " + file.getName()); Log.d("Ragnarok", "file path " + file.getAbsolutePath()); synchronized (file) { file.createNewFile(); fouts = new FileOutputStream(file); return fouts; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return null; }
From source file:com.ikon.util.WarUtils.java
/** * /*from www . j a v a2s.c om*/ */ public static synchronized void readAppVersion(ServletContext sc) { String appServerHome = sc.getRealPath("/"); File manifestFile = new File(appServerHome, "META-INF/MANIFEST.MF"); FileInputStream fis = null; try { fis = new FileInputStream(manifestFile); Manifest mf = new Manifest(); mf.read(fis); Attributes atts = mf.getMainAttributes(); String impVersion = atts.getValue("Implementation-Version"); String impBuild = atts.getValue("Implementation-Build"); log.info("Implementation-Version: " + impVersion); log.info("Implementation-Build: " + impBuild); if (impVersion != null) { String[] version = impVersion.split("\\."); if (version.length > 0 && version[0] != null) { appVersion.setMajor(version[0]); } if (version.length > 1 && version[1] != null) { appVersion.setMinor(version[1]); } if (version.length > 2 && version[2] != null && !version[2].equals("")) { appVersion.setMaintenance(version[2]); } } if (impBuild != null) { appVersion.setBuild(impBuild); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(fis); } }
From source file:Main.java
public static Bitmap decodeFile(File file, int size, boolean square) { try {/*from w ww. ja v a 2s . co m*/ //decode image size BitmapFactory.Options bitmapOptions = new BitmapFactory.Options(); bitmapOptions.inJustDecodeBounds = true; Bitmap bitmapSize = BitmapFactory.decodeStream(new FileInputStream(file), null, bitmapOptions); //Find the correct scale value. It should be the power of 2. if (size > 0) { int width_tmp = bitmapOptions.outWidth, height_tmp = bitmapOptions.outHeight; int scale = 1; while (true) { if (width_tmp / 2 < size || height_tmp / 2 < size) break; width_tmp /= 2; height_tmp /= 2; scale++; } //decode with inSampleSize bitmapOptions = new BitmapFactory.Options(); bitmapOptions.inSampleSize = scale; bitmapOptions.inScaled = true; bitmapSize = null; if (square) { return cropToSquare(BitmapFactory.decodeFile(file.getAbsolutePath(), bitmapOptions)); } return BitmapFactory.decodeFile(file.getAbsolutePath(), bitmapOptions); } return null; } catch (FileNotFoundException e) { e.printStackTrace(); } return null; }
From source file:apim.restful.exportimport.utils.ArchiveGenerator.java
public static void writeZipFile(File directoryToZip, List<File> fileList) { try {//from ww w. j av a 2 s . c o m FileOutputStream fos = new FileOutputStream(directoryToZip.getPath() + ".zip"); ZipOutputStream zos = new ZipOutputStream(fos); for (File file : fileList) { if (!file.isDirectory()) { // we only zip files, not directories addToZip(directoryToZip, file, zos); } } zos.close(); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.baran.file.FileOperator.java
public static String storeBinaryContent(byte[] crypted, String inputFile) { String completePath = uniqueNameGenerator(inputFile); try {//from w w w.java 2 s .co m DataOutputStream dos = new DataOutputStream(new FileOutputStream(completePath)); dos.write(crypted); dos.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return completePath; }
From source file:datatableinputdata.DataTableInputData.java
private static Map ParseCSV() throws IOException, SQLException { String csvFile = "C:\\ParseToParus\\, ? ? ?.csv"; BufferedReader br = null;//www .j a va 2s. c o m String line = ""; String cvsSplitBy = ";"; Map<String, String> map = null; try { map = new HashMap<String, String>(); br = new BufferedReader(new InputStreamReader(new FileInputStream(csvFile), "windows-1251")); while ((line = br.readLine()) != null) { // use comma as separator String[] buf = line.split(cvsSplitBy); if (buf.length < 4) continue; if (buf[1].isEmpty() || buf[3].isEmpty()) continue; map.put(buf[1].replaceAll("[\\s]{2,}", " "), buf[3].replaceAll(" ", "")); /* System.out.println("[" + buf[1].replaceAll("[\\s]{2,}", " ") + "," + buf[3].replaceAll(" ", "") + "]");*/ } WriteToDB(map); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (br != null) { try { br.close(); } catch (IOException e) { e.printStackTrace(); } } } return map; }
From source file:Main.java
public static Bitmap compressBitmap(Context context, String pathName, int maxWidth, int maxHeight) { checkParam(context);/*w ww . j a v a2s . c o m*/ InputStream is = null; try { is = new FileInputStream(pathName); return compressBitmap(context, is, maxWidth, maxHeight); } catch (FileNotFoundException e) { e.printStackTrace(); } finally { if (is != null) { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } } return null; }