List of usage examples for java.io IOException getMessage
public String getMessage()
From source file:org.excalibur.core.util.Properties2.java
public static Properties load(InputStream inStream) { Properties properties = new Properties(); try {/*w w w. j a va 2s .co m*/ properties.load(inStream); } catch (IOException e) { LOGGER.error("Error on loading the properties. Error message: {}", e.getMessage()); AnyThrow.throwUncheked(e); } return properties; }
From source file:kaljurand_at_gmail_dot_com.diktofon.NetSpeechApiUtils.java
/** * <p>Returns transcription that corresponds to the given token, * returns null if the transcription is not available, * throws an exception if a problem occurs.</p> *///from w w w. j a v a2 s .com public static String tokenToTrans(String token) throws TransException { //return mockTokenToTrans(token); TranscriptionDownloader td = new TranscriptionDownloader(); td.setUserAgentComment(USER_AGENT_DIKTOFON); String trans = null; try { trans = td.download(token); } catch (IOException e) { throw new TransException(e.getMessage()); } return trans; }
From source file:org.linkedeconomy.espa.service.impl.rdf.SellersImpl.java
public static void espaSellers() { ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml"); SellersService sellers = (SellersService) ctx.getBean("sellersServiceImpl"); List<Sellers> seller = sellers.getSellers(); //--------------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 (Sellers seller1 : seller) { Resource instanceSeller = infModel .createResource(OntologySpecification.instancePrefix + "Organization/" + seller1.getId()); infModel.add(instanceSeller, RDF.type, OntologySpecification.organizationResource); instanceSeller.addProperty(OntologySpecification.name, seller1.getEponimia(), XSDDatatype.XSDstring); }//w w w . j a v a 2s. c o m try { FileOutputStream fout = new FileOutputStream( "/Users/giovaf/Documents/yds_pilot1/espa_tests/22-02-2016_ouput/sellersEspa.rdf"); model.write(fout); } catch (IOException e) { System.out.println("Exception caught" + e.getMessage()); } }
From source file:com.canoo.webtest.boundary.StreamBoundary.java
/** * Close an InputStream and abort step if an error occur. * * Wraps IOException's.// w ww . j a v a 2 s . c o m * * @param is * @param step */ public static void tryCloseInputStreamWithFail(final InputStream is, final Step step) { if (is != null) { try { is.close(); } catch (IOException e) { LOG.error(e.getMessage(), e); throw new StepExecutionException("Error closing stream: " + e.getMessage(), step); } } }
From source file:com.canoo.webtest.boundary.StreamBoundary.java
/** * Close an OutputStream and abort step if an error occur. * * Wraps IOException's./*w w w . ja v a 2 s.com*/ * * @param os * @param step */ public static void tryCloseOutputStream(final OutputStream os, final Step step) { if (os != null) { try { os.close(); } catch (IOException e) { LOG.error(e.getMessage(), e); throw new StepExecutionException("Error closing stream: " + e.getMessage(), step); } } }
From source file:com.krawler.portal.util.SystemEnv.java
public static Properties getProperties() { Properties props = new Properties(); try {/*from ww w. j a va 2 s . co m*/ Runtime runtime = Runtime.getRuntime(); Process process = null; String osName = System.getProperty("os.name").toLowerCase(); if (osName.indexOf("windows ") > -1) { if (osName.indexOf("windows 9") > -1) { process = runtime.exec("command.com /c set"); } else { process = runtime.exec("cmd.exe /c set"); } } else { process = runtime.exec("env"); } BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; while ((line = br.readLine()) != null) { int pos = line.indexOf(StringPool.EQUAL); if (pos != -1) { String key = line.substring(0, pos); String value = line.substring(pos + 1); props.setProperty(key, value); } } } catch (IOException ioe) { logger.warn(ioe.getMessage(), ioe); } return props; }
From source file:de.jensd.addon.decoder.utils.ByteArray.java
public static String asJSONFormatted(byte[] payload) { String jsonString = asString(payload); ObjectMapper mapper = new ObjectMapper(); String result;//from ww w .ja va 2 s . com try { Object json = mapper.readValue(jsonString, Object.class); result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(json); } catch (IOException ex) { result = "*** PAYLOAD IS NOT VALID JSON DATA *** \n\n" + ex.getMessage(); } return result; }
From source file:Main.java
/** * Determines if the given stream contains XML content. The stream will be * buffered and reset if necessary./*from w ww .j a v a2 s . c om*/ * * @param stream * The InputStream to read. * @return true if the stream contains XML content; false otherwise. */ public static boolean isXML(InputStream stream) { if (!stream.markSupported()) { stream = new BufferedInputStream(stream, 1024); } stream.mark(1024); byte[] bytes = new byte[1024]; try { try { stream.read(bytes); } finally { stream.reset(); } } catch (IOException iox) { throw new RuntimeException("Failed to read or reset stream. " + iox.getMessage()); } try { XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader reader = factory.createXMLStreamReader(new ByteArrayInputStream(bytes)); // If XML, now in START_DOCUMENT state; seek document element. reader.nextTag(); } catch (XMLStreamException xse) { return false; } return true; }
From source file:com.hybridbpm.ui.component.chart.util.DiagrammeUtil.java
public static <T> T stringToObject(String json, Class<T> clazz) { T result = null;/*from w ww . jav a 2 s. co m*/ try { ObjectMapper mapper = new ObjectMapper(); // mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); result = (T) mapper.readValue(json, clazz); } catch (IOException ex) { LOG.log(Level.SEVERE, ex.getMessage(), ex); } return result; }
From source file:gui.TesteHackathon.java
public static void enviaImagem() { String server = "www.ejec.co"; int port = 21; String user = "ejec"; String pass = "cPanel2015"; FTPClient ftpClient = new FTPClient(); try {/*from w ww . ja v a2 s.c o m*/ ftpClient.connect(server, port); ftpClient.login(user, pass); ftpClient.enterLocalPassiveMode(); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); // APPROACH #1: uploads first file using an InputStream File firstLocalFile = new File("image.jpg"); String firstRemoteFile = "public_html/virtualfit/image.jpg"; InputStream inputStream = new FileInputStream(firstLocalFile); System.out.println("Start uploading first file"); boolean done = ftpClient.storeFile(firstRemoteFile, inputStream); inputStream.close(); if (done) { System.out.println("The first file is uploaded successfully."); } } catch (IOException ex) { System.out.println("Error: " + ex.getMessage()); ex.printStackTrace(); } finally { try { if (ftpClient.isConnected()) { ftpClient.logout(); ftpClient.disconnect(); } } catch (IOException ex) { ex.printStackTrace(); } } }