List of usage examples for java.io FileNotFoundException getMessage
public String getMessage()
From source file:com.aurel.track.lucene.index.associatedFields.textExctractor.RTFExtractor.java
/** * Gets the text from file content /*from w w w. j a v a2s.co m*/ * @param file * @param fileExtension * @return */ @Override public String getText(File file, String fileExtension) { FileInputStream fis = null; Reader reader = null; try { DefaultStyledDocument dsd = new DefaultStyledDocument(); RTFEditorKit rtfEditorKit = new RTFEditorKit(); try { fis = new FileInputStream(file); } catch (FileNotFoundException e) { LOGGER.info("File " + file.getName() + " not found. " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); return null; } reader = new BufferedReader(new InputStreamReader(fis)); rtfEditorKit.read(reader, dsd, 0); return dsd.getText(0, dsd.getLength()); } catch (Exception e) { if (LOGGER.isDebugEnabled()) { LOGGER.debug( "Extracting text from the .rtf file " + file.getName() + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } return null; } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { LOGGER.debug( "Closing the reader for file " + file.getName() + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } if (fis != null) { try { fis.close(); } catch (IOException e) { LOGGER.debug("Closing the FileInputStream for file " + file.getName() + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } } }
From source file:io.card.development.recording.Recording.java
public Recording(File zipfile) { try {// w w w . ja v a 2 s .c o m FileInputStream fileStream = new FileInputStream(zipfile); BufferedInputStream bufStream = new BufferedInputStream(fileStream); recordingContents = unzipFiles(bufStream); assert recordingContents != null; Log.d(TAG, String.format("recording has %d items", recordingContents.size())); Log.d(TAG, "keys: "); manifestEntries = ManifestEntry.getManifest(recordingContents); } catch (FileNotFoundException e) { Log.e(TAG, e.getMessage()); } catch (IOException e) { Log.e(TAG, e.getMessage(), e); } }
From source file:com.googlecode.t7mp.steps.CopyUserConfigStep.java
@Override public void execute(Context context) { // setup fields this.catalinaBaseDir = context.getConfiguration().getCatalinaBase(); this.userConfigDir = context.getConfiguration().getTomcatConfigDirectory(); this.configuration = context.getConfiguration(); this.log = context.getLog(); ///*from www.ja v a 2 s . c om*/ if (userConfigDir == null) { log.info("No directory for userConfigFiles configured."); return; } if (!userConfigDir.exists() || !userConfigDir.isDirectory()) { log.warn("The configured Directory for configuration files does not exist. " + userConfigDir.getAbsolutePath()); log.warn("Ignoring user configuration."); } if (userConfigDir.exists() && userConfigDir.isDirectory()) { File[] files = userConfigDir.listFiles(new FilesOnlyFileFilter()); for (File configFile : files) { try { if (configFile.getName().equals("catalina.properties")) { mergeUserCatalinaPropertiesWithDefault(configFile); continue; } log.debug("Copy provided config file '" + configFile.getName() + "' to " + catalinaBaseDir.getAbsolutePath() + "/conf/" + configFile.getName()); this.setupUtil.copy(new FileInputStream(configFile), new FileOutputStream(new File(catalinaBaseDir, "/conf/" + configFile.getName()))); } catch (FileNotFoundException e) { throw new TomcatSetupException(e.getMessage(), e); } catch (IOException e) { throw new TomcatSetupException(e.getMessage(), e); } } } }
From source file:com.googlecode.t7mp.TomcatConfigFilesSetup.java
public void copyUserConfigs(File userConfigDir) { if (userConfigDir == null) { log.info("No directory for userConfigFiles configured."); return;//from w ww. ja va 2s.co m } if (!userConfigDir.exists() || !userConfigDir.isDirectory()) { log.warn("The configured Directory for configuration files does not exist. " + userConfigDir.getAbsolutePath()); log.warn("Ignoring user configuration."); } if (userConfigDir.exists() && userConfigDir.isDirectory()) { File[] files = userConfigDir.listFiles(new FilesOnlyFileFilter()); for (File configFile : files) { try { if (configFile.getName().equals("catalina.properties")) { mergeUserCatalinaPropertiesWithDefault(configFile); continue; } log.debug("Copy provided config file '" + configFile.getName() + "' to " + catalinaBaseDir.getAbsolutePath() + "/conf/" + configFile.getName()); this.setupUtil.copy(new FileInputStream(configFile), new FileOutputStream(new File(catalinaBaseDir, "/conf/" + configFile.getName()))); } catch (FileNotFoundException e) { throw new TomcatSetupException(e.getMessage(), e); } catch (IOException e) { throw new TomcatSetupException(e.getMessage(), e); } } } }
From source file:fr.paris.lutece.plugins.updater.service.catalog.CatalogService.java
/** * Load a catalog list from a reader object * @param reader The reader/*www . j a v a 2s. com*/ */ private void loadCatalogsList(Reader reader) { // Configure Digester from XML ruleset URL rules = getClass().getResource(FILE_CATALOGS_LIST_RULES); Digester digester = DigesterLoader.createDigester(rules); // Push empty List onto Digester's Stack digester.push(this); try { digester.parse(reader); } catch (FileNotFoundException e) { AppLogService.error(EXCEPTION_MESSAGE + e.getMessage(), e); } catch (SAXException e) { AppLogService.error(EXCEPTION_MESSAGE + e.getMessage(), e); } catch (IOException e) { AppLogService.error(EXCEPTION_MESSAGE + e.getMessage(), e); } }
From source file:fr.paris.lutece.plugins.updater.service.catalog.CatalogService.java
/** * Load a catalog from a reader object// ww w.j av a2 s . c om * @param reader The reader */ private void load(Reader reader) { // Configure Digester from XML ruleset URL rules = getClass().getResource(FILE_CATALOG_RULES); Digester digester = DigesterLoader.createDigester(rules); // Push empty List onto Digester's Stack digester.push(this); try { digester.parse(reader); } catch (FileNotFoundException e) { AppLogService.error(EXCEPTION_MESSAGE + e.getMessage(), e); } catch (SAXException e) { AppLogService.error(EXCEPTION_MESSAGE + e.getMessage(), e); } catch (IOException e) { AppLogService.error(EXCEPTION_MESSAGE + e.getMessage(), e); } }
From source file:blast.shell.jline.BlastConsoleFactory.java
/** * Tries to load from welcomeMessage and then welcomeMessageFile, in that order... failing that, it will return * an empty Properties object.//from w ww. j a v a2 s. c o m * * @return */ protected Properties loadBrandingProperties() { if (welcomeMessage != null) { Properties props = new Properties(); props.put("welcome", welcomeMessage); return props; } else if (welcomeMessageFile != null) { try { ResourceUtils.getFile(welcomeMessageFile); } catch (FileNotFoundException e) { log.error("Could not find file " + welcomeMessageFile + ": " + e.getMessage()); } } // failed... no welcome message for you. return new Properties(); }
From source file:mx.com.gaby.service.AsynchronousService.java
private void serializeFile() { try {//from w ww . j ava 2 s .c om File file = new File("C:\\Users\\iam_g\\Downloads\\alto.pdf"); InputStream isNew = new FileInputStream(file); byte[] bytes = IOUtils.toByteArray(isNew); String codigoMd5 = Md5Converter.calculaMD5(bytes); Long maxMemory = Runtime.getRuntime().maxMemory(); int[] matrix = new int[(int) (maxMemory + 1)]; for (int i = 0; i < matrix.length; ++i) { matrix[i] = i + 1; } System.out.println("Serializando archivo: [Tamao: " + file.length() + "][" + maxMemory + "]" + "[" + file.getName() + "][" + codigoMd5 + "][" + bytes.length + "]"); } catch (FileNotFoundException fnfe) { System.out.println("FileNotFoundException: " + fnfe.getMessage()); } catch (IOException ioe) { System.out.println("IOException: " + ioe.getMessage()); } }
From source file:curam.molsa.test.customfunctions.MOLSAMockDataStore.java
/** * this is to Creates a Mock Datastore./* w ww . j a v a2 s. c o m*/ * @param datastoreFile * @return root * @throws AppException */ private Entity createTestDataStore(final File datastoreFile) throws AppException { final MOLSADatastoreStruct mOLSADatastoreStruct = new MOLSADatastoreStruct(); try { mOLSADatastoreStruct.setDatastoreID(datastore.initialize(schemaName)); } catch (final AppException e) { fail(e.getMessage()); } FileInputStream fileInputStream = null; try { fileInputStream = new FileInputStream(datastoreFile); } catch (final FileNotFoundException e1) { e1.printStackTrace(); fail(e1.getMessage()); } try { // read the xml mOLSADatastoreStruct.setXml(IOUtils.toString(fileInputStream)); } catch (final IOException e) { fail(e.getMessage()); } datastore.save(mOLSADatastoreStruct, schemaName); final Entity root = datastore.read(mOLSADatastoreStruct.getDatastoreID(), schemaName); root.setAttribute("submitDate", "20130321"); root.update(); return root; }
From source file:de.hybris.platform.acceleratorservices.cronjob.SiteMapMediaJob.java
protected CatalogUnawareMediaModel createCatalogUnawareMediaModel(final File siteMapFile) { final CatalogUnawareMediaModel media = modelService.create(CatalogUnawareMediaModel.class); media.setCode(siteMapFile.getName()); modelService.save(media);/* w w w. j a v a 2 s . c o m*/ try { getMediaService().setStreamForMedia(media, new FileInputStream(siteMapFile), siteMapFile.getName(), SITE_MAP_MIME_TYPE); } catch (final FileNotFoundException e) { LOG.error(e.getMessage()); } return media; }