List of usage examples for java.io FileNotFoundException printStackTrace
public void printStackTrace()
From source file:cloud.elasticity.elastman.Props.java
public static void save(String filename) { properties.setProperty("username", username); properties.setProperty("password", password); properties.setProperty("keyname", keyname); properties.setProperty("zone", zone); properties.setProperty("endpoint", endpoint); properties.setProperty("webSyncServer", webSyncServer); properties.setProperty("server.port", "" + server_port); properties.setProperty("ident.client.min", "" + ident_client_min); properties.setProperty("ident.client.max", "" + ident_client_max); properties.setProperty("ident.client.delta", "" + ident_client_delta); properties.setProperty("ident.client.delay", "" + ident_client_delay); properties.setProperty("ident.period", "" + ident_period); properties.setProperty("ident.sampling", "" + ident_sampling); properties.setProperty("ident.client.manual", "" + ident_client_manual); properties.setProperty("control.interval", "" + control_interval); properties.setProperty("cloud.voldVMs", "" + voldCount); properties.setProperty("act.createVMs", "" + createVMs); properties.setProperty("act.voldMax", "" + voldMax); properties.setProperty("act.voldMin", "" + voldMin); properties.setProperty("act.voldDeltaMax", "" + voldDeltaMax); properties.setProperty("control.kp", "" + control_kp); properties.setProperty("control.ki", "" + control_ki); properties.setProperty("control.kd", "" + control_kd); properties.setProperty("control.inOp", "" + control_inOp); properties.setProperty("control.outOp", "" + control_outOp); properties.setProperty("filter.alpha", "" + filter_alpha); properties.setProperty("control.warmup", "" + control_warmup); properties.setProperty("control.dead", "" + control_dead); properties.setProperty("control.ff.throughputDelta", "" + control_ff_throughputDelta); properties.setProperty("control.ff.r1", "" + control_ffr1); properties.setProperty("control.ff.w1", "" + control_ffw1); properties.setProperty("control.ff.r2", "" + control_ffr2); properties.setProperty("control.ff.w2", "" + control_ffw2); properties.setProperty("voldPrefix", voldPrefix); properties.setProperty("voldImage", voldImage); properties.setProperty("voldFlavor", voldFlavor); properties.setProperty("voldReplicationFactor", "" + voldReplicationFactor); properties.setProperty("ycsbPrefix", ycsbPrefix); properties.setProperty("ycsbImage", ycsbImage); properties.setProperty("ycsbFlavor", ycsbFlavor); // properties.setProperty(, ""+); // properties.setProperty(, ""+); // properties.setProperty(, ""+); // properties.setProperty(, ""+); // properties.setProperty(, ""+); FileOutputStream propFile;//from www . j av a 2 s. co m try { propFile = new FileOutputStream(filename); properties.store(propFile, "ElastMan Configurations File"); } catch (FileNotFoundException e) { log.error(e.getMessage()); e.printStackTrace(); } catch (IOException e) { log.error(e.getMessage()); e.printStackTrace(); } }
From source file:com.cws.esolutions.security.listeners.SecurityServiceInitializer.java
/** * Initializes the security service in a standalone mode - used for applications outside of a container or when * run as a standalone jar./*ww w . j av a 2s .co m*/ * * @param configFile - The security configuration file to utilize * @param logConfig - The logging configuration file to utilize * @param startConnections - Configure, load and start repository connections * @throws SecurityServiceException @{link com.cws.esolutions.security.exception.SecurityServiceException} * if an exception occurs during initialization */ public static void initializeService(final String configFile, final String logConfig, final boolean startConnections) throws SecurityServiceException { URL xmlURL = null; JAXBContext context = null; Unmarshaller marshaller = null; SecurityConfigurationData configData = null; final ClassLoader classLoader = SecurityServiceInitializer.class.getClassLoader(); final String serviceConfig = (StringUtils.isBlank(configFile)) ? System.getProperty("configFileFile") : configFile; final String loggingConfig = (StringUtils.isBlank(logConfig)) ? System.getProperty("secLogConfig") : logConfig; try { try { DOMConfigurator.configure(Loader.getResource(loggingConfig)); } catch (NullPointerException npx) { try { DOMConfigurator.configure(FileUtils.getFile(loggingConfig).toURI().toURL()); } catch (NullPointerException npx1) { System.err.println("Unable to load logging configuration. No logging enabled!"); System.err.println(""); npx1.printStackTrace(); } } xmlURL = classLoader.getResource(serviceConfig); if (xmlURL == null) { // try loading from the filesystem xmlURL = FileUtils.getFile(serviceConfig).toURI().toURL(); } context = JAXBContext.newInstance(SecurityConfigurationData.class); marshaller = context.createUnmarshaller(); configData = (SecurityConfigurationData) marshaller.unmarshal(xmlURL); SecurityServiceInitializer.svcBean.setConfigData(configData); if (startConnections) { DAOInitializer.configureAndCreateAuthConnection( new FileInputStream(FileUtils.getFile(configData.getSecurityConfig().getAuthConfig())), false, SecurityServiceInitializer.svcBean); Map<String, DataSource> dsMap = SecurityServiceInitializer.svcBean.getDataSources(); if (DEBUG) { DEBUGGER.debug("dsMap: {}", dsMap); } if (configData.getResourceConfig() != null) { if (dsMap == null) { dsMap = new HashMap<String, DataSource>(); } for (DataSourceManager mgr : configData.getResourceConfig().getDsManager()) { if (!(dsMap.containsKey(mgr.getDsName()))) { StringBuilder sBuilder = new StringBuilder() .append("connectTimeout=" + mgr.getConnectTimeout() + ";") .append("socketTimeout=" + mgr.getConnectTimeout() + ";") .append("autoReconnect=" + mgr.getAutoReconnect() + ";") .append("zeroDateTimeBehavior=convertToNull"); if (DEBUG) { DEBUGGER.debug("StringBuilder: {}", sBuilder); } BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(mgr.getDriver()); dataSource.setUrl(mgr.getDataSource()); dataSource.setUsername(mgr.getDsUser()); dataSource.setConnectionProperties(sBuilder.toString()); dataSource.setPassword(PasswordUtils.decryptText(mgr.getDsPass(), mgr.getDsSalt(), configData.getSecurityConfig().getSecretAlgorithm(), configData.getSecurityConfig().getIterations(), configData.getSecurityConfig().getKeyBits(), configData.getSecurityConfig().getEncryptionAlgorithm(), configData.getSecurityConfig().getEncryptionInstance(), configData.getSystemConfig().getEncoding())); if (DEBUG) { DEBUGGER.debug("BasicDataSource: {}", dataSource); } dsMap.put(mgr.getDsName(), dataSource); } } if (DEBUG) { DEBUGGER.debug("dsMap: {}", dsMap); } SecurityServiceInitializer.svcBean.setDataSources(dsMap); } } } catch (JAXBException jx) { jx.printStackTrace(); throw new SecurityServiceException(jx.getMessage(), jx); } catch (FileNotFoundException fnfx) { fnfx.printStackTrace(); throw new SecurityServiceException(fnfx.getMessage(), fnfx); } catch (MalformedURLException mux) { mux.printStackTrace(); throw new SecurityServiceException(mux.getMessage(), mux); } catch (SecurityException sx) { sx.printStackTrace(); throw new SecurityServiceException(sx.getMessage(), sx); } }
From source file:com.kabootar.GlassMemeGenerator.ImageOverlay.java
public static boolean saveToSD(final Bitmap overlaid, final String sdPath, final String fileName) { boolean isItSaved = false; new AsyncTask<Void, Void, Void>() { @Override//from w ww . j av a 2 s. c o m protected Void doInBackground(Void... arg0) { File image = new File(sdPath, fileName); FileOutputStream outStream; try { outStream = new FileOutputStream(image); //resize image Bitmap newoverlaid = getResizedBitmap(overlaid, 1000, 1362); newoverlaid.compress(Bitmap.CompressFormat.PNG, 100, outStream); outStream.flush(); outStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) { int width = bm.getWidth(); int height = bm.getHeight(); float scaleWidth = ((float) newWidth) / width; float scaleHeight = ((float) newHeight) / height; // CREATE A MATRIX FOR THE MANIPULATION Matrix matrix = new Matrix(); // RESIZE THE BIT MAP matrix.postScale(scaleWidth, scaleHeight); // "RECREATE" THE NEW BITMAP Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false); return resizedBitmap; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); } }.execute(); return isItSaved; }
From source file:blue.soundObject.pianoRoll.Scale.java
public static Scale loadScale(File scalaFile) { Scale scale = new Scale(); scale.setScaleName(scalaFile.getName()); ArrayList lines;/* w w w . ja va 2 s .c om*/ try { /* * Scala is capable of writing a .scl file with no description, * which results in an empty line. Parsing it as a series of lines * allows us to "see" the empty line and handle it properly, whereas * using StringTokenizer("\n") makes the empty line "disappear", * resulting in a parsing error. This approach is probably faster as * well. */ lines = TextUtilities.getLinesFromFile(scalaFile, true); } catch (FileNotFoundException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } int lineCount = 0; int pitchCount = 0; int index = 0; int count = lines.size(); for (int i = 0; i < count; i++) { String line = (String) lines.get(i); if (line.startsWith("!")) { // Comment continue; } if (lineCount == 0) { // Description Line // scale.scaleName = line.trim(); } else if (lineCount == 1) { // Pitch count pitchCount = Integer.parseInt(line); scale.ratios = new float[pitchCount]; scale.ratios[0] = 1.0f; index++; } else { // Ratios if (scale.ratios != null) { if (index == scale.ratios.length) { scale.octave = getMultiplier(line); } else { scale.ratios[index] = getMultiplier(line); index++; } } } lineCount++; } return scale; }
From source file:de.helmholtz_muenchen.ibis.utils.ngs.samsplitter.helpers.FileHelpers.java
/** * Returns md5 sum for a given file/* ww w .j ava 2s. co m*/ * @param file * @return */ public static String getmd5Sum(String file) { FileInputStream fis; try { fis = new FileInputStream(new File(file)); String md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis); fis.close(); return md5; } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ""; }
From source file:gr.kzps.FileCrypto.executor.Executor.java
/** * Call the dispatcher// www . ja v a2 s . c om * * @param operation * Encryption or decryption * @param inputDir * Directory where the files to be encrypted/decrypted reside * @param outputDir * Output directory of the cryptographics operation * @param cryptoKey * Cryptographic key */ private static void callDispatcher(CryptoOperation operation, String inputDir, String outputDir, Integer threshold, String cryptoKey) { try { Dispatcher.dispatch(operation, inputDir, outputDir, threshold, cryptoKey); } catch (FileNotFoundException ex) { log.error("Error {}", new Object[] { ex.getMessage() }); } catch (NotDirectoryException ex) { log.error("Error {}", new Object[] { ex.getMessage() }); } catch (InterruptedException ex) { ex.printStackTrace(); } catch (NoCryptoKeyProvided ex) { log.error("Error {}", new Object[] { ex.getMessage() }); } }
From source file:ac.ucy.cs.spdx.license.License.java
/** * Loads all the licenses that are saved in the standard directory into * License objects./* ww w . jav a2s . c o m*/ * */ public static void loadLicenses() { File licensesText = new File("licensesText/"); if (licensesText.isDirectory()) { File[] files = licensesText.listFiles(); for (File f : files) { FileReader fr; try { fr = new FileReader(f); BufferedReader br = new BufferedReader(fr); String lName = br.readLine(); String lIdentifier = br.readLine(); if (licenseExists(lIdentifier)) continue; new License(lName, lIdentifier, f); br.close(); fr.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:com.wisc.cs407project.ImageLoader.ImageLoader.java
public static Bitmap decodeFile(File f) { try {//from w ww .j av a2s .co m //decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; FileInputStream stream1 = new FileInputStream(f); BitmapFactory.decodeStream(stream1, null, o); stream1.close(); //Find the correct scale value. It should be the power of 2. int width_tmp = o.outWidth, height_tmp = o.outHeight; int scale = 1; while (true) { if (width_tmp / 2 < REQUIRED_WIDTH && height_tmp / 2 < REQUIRED_HEIGHT) break; width_tmp /= 2; height_tmp /= 2; scale *= 2; } //decode with inSampleSize BitmapFactory.Options o2 = new BitmapFactory.Options(); o2.inSampleSize = scale; FileInputStream stream2 = new FileInputStream(f); Bitmap bitmap = BitmapFactory.decodeStream(stream2, null, o2); stream2.close(); return bitmap; } catch (FileNotFoundException e) { } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:com.hw13c.HttpClientPost.java
public static void getRdf() { String queryString = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" + " PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " + " PREFIX dbpprop: <http://dbpedia.org/property/> " + " PREFIX dbpedia: <http://dbpedia.org/resource/> " + " PREFIX dbpedia-owl: <http://dbpedia.org/ontology/> " + " SELECT DISTINCT (STR(?person1) as ?person)" + " WHERE {<rdf:type rdf:resource='http://s.opencalais.com/1/type/em/e/Person'/> <c:name> ?person}"; try {//from ww w .ja va 2s . co m FileOutputStream file = new FileOutputStream("outputHW13.txt"); ResultSet results = queryDBPedia(queryString); Query query = QueryFactory.create(queryString); ResultSetFormatter.out(file, results, query); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { ResultSet resultSet; resultSet = queryDBPedia(queryString); executeQueries(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:dm_p2.DBSCAN.java
public static void generateLinkedHashMap(String filename) { String filePath = new File("").getAbsolutePath(); try {//from w ww .j a va 2 s .c o m Scanner s = new Scanner(new File(filePath + "/src/dm_p2/" + filename)); while (s.hasNext()) { String inputLine = s.nextLine(); String[] splitData = inputLine.split("\t"); int geneId = Integer.parseInt(splitData[0]); expressionValues = new ArrayList<Double>(); int cc = Integer.parseInt(splitData[1]); given.put(geneId, cc); for (int i = 2; i < splitData.length; i++) { expressionValues.add(Double.parseDouble(splitData[i])); } // gene g=new gene(); // g.add(geneId, expressionValues); // genelist.add(g); linkedHashMap.put(geneId, expressionValues); } } catch (FileNotFoundException e) { e.printStackTrace(); } }