List of usage examples for java.io IOException getMessage
public String getMessage()
From source file:de.rub.syssec.saaf.analysis.steps.cleanup.DeleteFilesStep.java
/** * Delete all related app data./*from ww w .ja va 2s .com*/ * @param app */ private static boolean deleteAppData(ApplicationInterface app) { // Directory may be null if, eg, the file magic does not match and hence nothing was unpacked if (app != null && app.getApplicationDirectory() != null) { if (app.getApplicationDirectory().exists()) { try { FileUtils.deleteDirectory(app.getApplicationDirectory()); } catch (IOException e) { LOGGER.error("Could not delete directory: " + e.getMessage()); return false; } } File appCopy = new File(Config.getInstance().getConfigValue(ConfigKeys.DIRECTORY_APPS, "apps") + File.separator + app.getApplicationName() + "." + app.getFileExtension()); if (appCopy.exists()) { appCopy.delete(); } } return true; }
From source file:com.cmput301w15t15.travelclaimsapp.elasticsearch.parseResponse.java
/** * Gets rid of elastic search header and returns saved claimlist. * @param response/*from w w w . java 2 s.c om*/ * @return SearchHit<ClaimList> */ public static SearchHit<ClaimList> claimListHit(HttpResponse response) { try { String json = getEntityContent(response); Type searchHitType = new TypeToken<SearchHit<ClaimList>>() { }.getType(); SearchHit<ClaimList> sr = gson.fromJson(json, searchHitType); return sr; } catch (IOException e) { Log.d(TAG, "parseClaimListHit did not work: " + e.getMessage()); } return null; }
From source file:com.izforge.izpack.test.util.TestHelper.java
/** * Verifies that two files have the same content. * <p/>/*from w ww. j av a 2s . c o m*/ * The files must have different paths. * * @param expected the expected file * @param actual the actual file */ public static void assertFileEquals(File expected, File actual) { assertTrue(actual.exists()); assertFalse(actual.getAbsolutePath().equals(expected.getAbsolutePath())); assertEquals(expected.length(), actual.length()); try { assertEquals(FileUtils.checksumCRC32(expected), FileUtils.checksumCRC32(actual)); } catch (IOException exception) { fail(exception.getMessage()); } }
From source file:biz.paluch.maven.configurator.FileTemplating.java
/** * Process files which match the template pattern. Creates a new file using the input file with property * replacement. Target filename is without the template name part. * * @param log//from w ww .j av a 2s. c o m * @param root * @param processor * @throws IOException */ public static void processFiles(Log log, File root, TemplateProcessor processor) throws IOException { Iterator<File> iterator = FileUtils.iterateFiles(root, new RegexFileFilter(FILE_TEMPLATE_PATTERN), TrueFileFilter.TRUE); while (iterator.hasNext()) { File next = iterator.next(); log.debug("Processing file " + next); try { processor.processFile(next, getTargetFile(next)); } catch (IOException e) { throw new IOException("Cannot process file " + next.toString() + ": " + e.getMessage(), e); } } }
From source file:org.linkedeconomy.espa.service.impl.rdf.BuyersImpl.java
public static void espaBuyers() { ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml"); BuyersService buyers = (BuyersService) ctx.getBean("buyersServiceImpl"); List<Buyers> buyer = buyers.getBuyers(); List<Buyer> projectBuyer = buyers.getProjectBuyers(); //--------------RDF Model--------------// Model model = ModelFactory.createDefaultModel(); Reasoner reasoner = ReasonerRegistry.getOWLReasoner(); InfModel infModel = ModelFactory.createInfModel(reasoner, model); model.setNsPrefix("elod", OntologySpecification.elodPrefix); model.setNsPrefix("gr", OntologySpecification.goodRelationsPrefix); model.setNsPrefix("vcard", OntologySpecification.vcardPrefix); for (Buyer projectBuyer1 : projectBuyer) { Resource instanceBuyer = infModel.createResource( OntologySpecification.instancePrefix + "Organization/" + projectBuyer1.getBuyerId()); Resource instanceProject = infModel .createResource(OntologySpecification.instancePrefix + "Subsidy/" + projectBuyer1.getOps()); infModel.add(instanceBuyer, RDF.type, OntologySpecification.organizationResource); infModel.add(instanceProject, RDF.type, OntologySpecification.subsidyResource); instanceProject.addProperty(OntologySpecification.beneficiary, instanceBuyer); instanceBuyer.addProperty(OntologySpecification.name, String.valueOf(projectBuyer1.getEponimia()), XSDDatatype.XSDstring);/*from www. j a v a 2s. co m*/ } try { FileOutputStream fout = new FileOutputStream( "/Users/giovaf/Documents/yds_pilot1/espa_tests/22-02-2016_ouput/buyersEspa.rdf"); // /home/svaf/buyersEspa.rdf // /Users/giovaf/Documents/yds_pilot1/espa_tests/06-01-2016_output/buyersEspa.rdf model.write(fout); } catch (IOException e) { System.out.println("Exception caught" + e.getMessage()); } }
From source file:net.kungfoo.grizzly.proxy.impl.Activator.java
private static void startReactor() { Thread t = new Thread(new Runnable() { @SuppressWarnings({ "UseOfSystemOutOrSystemErr" }) public void run() { try { connectingIOReactor.execute(connectingEventDispatch); } catch (InterruptedIOException ex) { System.err.println("Interrupted"); } catch (IOException e) { System.err.println("I/O error: " + e.getMessage()); e.printStackTrace(System.err); }/*from www .ja v a2 s . co m*/ } }); t.start(); }
From source file:ch.elexis.importer.div.Helpers.java
static Path copyRscToTempDirectory() { Path path = null;//from ww w . ja v a 2s . co m try { path = Files.createTempDirectory("HL7_Test"); File src = new File(PlatformHelper.getBasePath("ch.elexis.core.ui.importer.div.tests"), "rsc"); System.out.println("src: " + src.toString()); FileUtils.copyDirectory(src, path.toFile()); } catch (IOException e) { System.out.println(e.getMessage()); e.printStackTrace(); } return path; }
From source file:de.micromata.genome.gwiki.utils.PropUtils.java
public static OrderedProperties toProperties(String text) { OrderedProperties props = new OrderedProperties(); if (StringUtils.isEmpty(text) == true) { return props; }/*from www . j av a 2s . co m*/ try { props.load(IOUtils.toInputStream(text, PROPS_ENCODING)); return props; } catch (IOException ex) { throw new RuntimeIOException("Failed to parse Property file: " + ex.getMessage(), ex); } }
From source file:com.gc.core.framework.utils.PropertiesUtils.java
/** * properties, ???.// w w w. ja va 2 s.c o m * Spring Resource?, ?UTF-8. * * @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer */ public static Properties loadProperties(String... resourcesPaths) throws IOException { Properties props = new Properties(); for (String location : resourcesPaths) { logger.debug("Loading properties file from:" + location); InputStream is = null; try { Resource resource = resourceLoader.getResource(location); is = resource.getInputStream(); propertiesPersister.load(props, new InputStreamReader(is, DEFAULT_ENCODING)); } catch (IOException ex) { logger.info("Could not load properties from classpath:" + location + ": " + ex.getMessage()); } finally { if (is != null) { is.close(); } } } return props; }
From source file:com.mobius.software.mqtt.performance.runner.util.FileUtil.java
public static void logErrors(UUID scenarioID, List<ClientReport> reports) { if (reports.isEmpty()) return;/* w ww . j a va2 s.c o m*/ String filename = DIRECTORY_NAME + File.separator + scenarioID.toString() + LOG_EXTENSION; File log = new File(filename); if (!log.getParentFile().exists()) log.getParentFile().mkdir(); try (PrintWriter pw = new PrintWriter(log)) { for (ClientReport clientReport : reports) { List<ErrorReport> errorReports = clientReport.getErrors(); if (!errorReports.isEmpty()) { String errorContent = ReportBuilder.buildError(clientReport.getIdentifier(), errorReports); pw.println(errorContent); } } } catch (IOException e) { logger.error("An error occured while writing error reports to file:" + e.getMessage()); } if (log.length() == 0) log.delete(); }