List of usage examples for java.io IOException toString
public String toString()
From source file:com.streamsets.pipeline.lib.parser.avro.AvroDataParserFactory.java
@Override public DataParser getParser(String id, InputStream is, String offset) throws DataParserException { try {//from w w w .ja va2s .c o m return new AvroDataStreamParser(getSettings().getContext(), schema, id, is, Long.parseLong(offset), getSettings().getOverRunLimit()); } catch (IOException e) { throw new DataParserException(Errors.DATA_PARSER_01, e.toString(), e); } }
From source file:com.streamsets.pipeline.lib.parser.avro.AvroDataParserFactory.java
@Override public DataParser getParser(File file, String fileOffset) throws DataParserException { try {/*from w w w. j a v a 2s. c o m*/ return new AvroDataFileParser(getSettings().getContext(), schema, file, fileOffset, getSettings().getOverRunLimit()); } catch (IOException e) { throw new DataParserException(Errors.DATA_PARSER_01, e.toString(), e); } }
From source file:com.cisco.oss.foundation.http.apache.ApacheHttpResponse.java
@Override public String getResponseAsString(String charset) { if (hasResponseBody()) { if (!isClosed) { try { return EntityUtils.toString(httpResponse.getEntity(), charset); } catch (IOException e) { throw new ClientException(e.toString(), e); }//from w ww .j a va 2s . com } else { try { return new String(responseBody, charset); } catch (UnsupportedEncodingException e) { LOGGER.error( "can't return string representation of the response with the charset: {}. error is: {}. Using default charset.", charset, e); return new String(responseBody); } } } else { return ""; } }
From source file:at.jps.sanction.model.queue.file.FileQueue.java
@Override public boolean addMessage(final X message) { try {//from w w w.ja va 2 s . c o m getQueue().enqueue(SerializationUtils.serialize((Serializable) message)); flush(); // TODO: this IS ugly ... super.addMessage(message); return true; } catch (final IOException e) { logger.error("Error adding Message:" + e.toString()); logger.debug("Exception: ", e); return false; } }
From source file:de.dal33t.powerfolder.test.transfer.BandwidthLimitText.java
public void testLimiteds() { BandwidthLimiter bl = BandwidthLimiter.LAN_INPUT_BANDWIDTH_LIMITER; bl.setAvailable(10000);// www . j a va 2 s . com byte b[] = new byte[1000]; ByteArrayOutputStream bout = new ByteArrayOutputStream(); try (LimitedOutputStream out = new LimitedOutputStream(bl, bout)) { out.write(b); } catch (IOException e) { fail(e.toString()); } assertTrue("Wrong amount left/write", bl.getAvailable() == 10000 - b.length); assertTrue("Wrong amount written", bout.size() == b.length); ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); bl.setAvailable(10000); int read = 0; try (LimitedInputStream in = new LimitedInputStream(bl, bin)) { read = in.read(b); } catch (IOException e) { fail(e.toString()); } assertTrue("Wrong amount left/read", bl.getAvailable() == 10000 - read); assertTrue("Wrong amount read", bin.available() == b.length - read); }
From source file:com.photon.phresco.nativeapp.unit.test.testcases.H_LoginActivityTest.java
/** * send valid login email id and password to web server * *///from w w w . j av a 2 s . c om @Test public final void testLoginCredantial() { JSONObject jObjMain = new JSONObject(); JSONObject jObj = new JSONObject(); try { PhrescoLogger.info(TAG + " testLoginCredantial -------------- START "); jObj.put("loginEmail", ""); jObj.put("password", "123"); jObjMain.put("login", jObj); JSONObject responseJSON = null; responseJSON = JSONHelper.postJSONObjectToURL( Constants.getWebContextURL() + Constants.getRestAPI() + Constants.LOGIN_POST_URL, jObjMain.toString()); assertNotNull("Login failed", responseJSON.length() > 0); PhrescoLogger.info(TAG + " testLoginCredantial -------------- END "); } catch (IOException ex) { PhrescoLogger.info(TAG + " - testLoginCredantial - IOException : " + ex.toString()); PhrescoLogger.warning(ex); } catch (JSONException ex) { PhrescoLogger.info(TAG + " - testLoginCredantial - JSONException : " + ex.toString()); PhrescoLogger.warning(ex); } }
From source file:org.matsim.counts.algorithms.graphs.helper.OutputDelegate.java
public void outputHtml() { new File(this.iterPath_ + "/png").mkdir(); for (CountsGraph cg : this.cg_list_) { writeHtml(cg, this.iterPath_, false); }//w ww.j a va 2 s . co m writeHtml(null, this.iterPath_, true); try { new File(this.iterPath_ + "/div").mkdir(); copyResourceToFile("style1.css", this.iterPath_ + "/div/style1.css"); copyResourceToFile("logo.png", this.iterPath_ + "/div/logo.png"); copyResourceToFile("overlib.js", this.iterPath_ + "/div/overlib.js"); copyResourceToFile("title.png", this.iterPath_ + "/div/title.png"); } catch (IOException e) { System.out.println(e.toString()); e.printStackTrace(); } }
From source file:com.redpill_linpro.libreoffice.LibreOfficeLauncherWindowsImpl.java
@Override public void launchLibreOffice(String cmisUrl, String repositoryId, String filePath, String webdavUrl) { Runtime rt = Runtime.getRuntime(); try {//from ww w . jav a2s . c om String params; if (null != webdavUrl && webdavUrl.length() > 0) { params = LibreOfficeLauncherHelper.generateLibreOfficeWebdavOpenUrl(webdavUrl); } else { params = LibreOfficeLauncherHelper.generateLibreOfficeCmisOpenUrl(cmisUrl, repositoryId, filePath); } StringBuffer cmd = new StringBuffer(); try { String[] binaryLocations = { "start soffice.exe" }; for (int i = 0; i < binaryLocations.length; i++) { cmd.append((i == 0 ? "" : " || ") + binaryLocations[i] + " \"" + params + "\" "); } System.out.println("Command: cmd.exe /C " + cmd); rt.exec(new String[] { "cmd.exe", "/C", cmd.toString() }); System.out.println("Process started"); } catch (IOException e) { JOptionPane.showMessageDialog(null, "Failed to start LibreOffice, commandline: " + cmd.toString() + "" + e.toString(), "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } catch (UnsupportedEncodingException e1) { JOptionPane.showMessageDialog(null, "Invalid URL for LibreOffice", "Error", JOptionPane.ERROR_MESSAGE); e1.printStackTrace(); } }
From source file:com.photon.phresco.nativeapp.unit.test.testcases.C_ProductListActivityTest.java
/** * get the product list from web server/*from w w w.j a v a2 s.c o m*/ * */ @Test public final void testGetProducts() { Product product = new Product(); try { PhrescoLogger.info(TAG + " testProduct -------------- START "); JSONObject productJSONObj = product.getProductJSONObject( Constants.getWebContextURL() + Constants.getRestAPI() + Constants.PRODUCTS_URL); assertNotNull(productJSONObj); JSONArray productArray = productJSONObj.getJSONArray("product"); assertTrue(productArray.length() > 0); PhrescoLogger.info(TAG + " testProduct -------------- END "); } catch (IOException ex) { PhrescoLogger.info(TAG + "testProduct - IOException: " + ex.toString()); PhrescoLogger.warning(ex); } catch (JSONException ex) { PhrescoLogger.info(TAG + "testProduct - JSONException: " + ex.toString()); PhrescoLogger.warning(ex); } }