List of usage examples for java.io IOException getLocalizedMessage
public String getLocalizedMessage()
From source file:it.geosolutions.figis.security.authentication.CredentialsManager.java
/** * *///from www . ja va 2 s . c o m public synchronized void reload() { // get new modified time final long tempModTime = propertyFile.lastModified(); // do we need to reload the properties file if (tempModTime > lastMod) { try { // reload loadProperties(); // update the modified time only when we actually succeed in reloading lastMod = tempModTime; } catch (IOException e) { if (LOGGER.isEnabledFor(Level.INFO)) { LOGGER.log(Level.INFO, e.getLocalizedMessage(), e); } } } }
From source file:com.nextgis.maplib.map.RemoteTMSLayer.java
@Override public Bitmap getBitmap(TileItem tile) { Bitmap ret;/*from ww w . j a va 2 s .com*/ // try to get tile from local cache File tilePath = new File(mPath, tile.toString("{z}/{x}/{y}" + TILE_EXT)); if (tilePath.exists() && System.currentTimeMillis() - tilePath.lastModified() < DEFAULT_MAXIMUM_CACHED_FILE_AGE) { ret = BitmapFactory.decodeFile(tilePath.getAbsolutePath()); if (ret != null) { return ret; } } if (!mNet.isNetworkAvailable()) { //return tile from cache ret = BitmapFactory.decodeFile(tilePath.getAbsolutePath()); return ret; } // try to get tile from remote String url = tile.toString(getURLSubdomain()); Log.d(TAG, "url: " + url); try { final HttpGet get = new HttpGet(url); //basic auth if (null != mLogin && mLogin.length() > 0 && null != mPassword && mPassword.length() > 0) { get.setHeader("Accept", "*/*"); final String basicAuth = "Basic " + Base64.encodeToString((mLogin + ":" + mPassword).getBytes(), Base64.NO_WRAP); get.setHeader("Authorization", basicAuth); } final DefaultHttpClient HTTPClient = mNet.getHttpClient(); final HttpResponse response = HTTPClient.execute(get); // Check to see if we got success final org.apache.http.StatusLine line = response.getStatusLine(); if (line.getStatusCode() != 200) { Log.d(TAG, "Problem downloading MapTile: " + url + " HTTP response: " + line); ret = BitmapFactory.decodeFile(tilePath.getAbsolutePath()); return ret; } final HttpEntity entity = response.getEntity(); if (entity == null) { Log.d(TAG, "No content downloading MapTile: " + url); ret = BitmapFactory.decodeFile(tilePath.getAbsolutePath()); return ret; } FileUtil.createDir(tilePath.getParentFile()); InputStream input = entity.getContent(); OutputStream output = new FileOutputStream(tilePath.getAbsolutePath()); byte data[] = new byte[IO_BUFFER_SIZE]; FileUtil.copyStream(input, output, data, IO_BUFFER_SIZE); output.close(); input.close(); ret = BitmapFactory.decodeFile(tilePath.getAbsolutePath()); return ret; } catch (IOException e) { Log.d(TAG, "Problem downloading MapTile: " + url + " Error: " + e.getLocalizedMessage()); } ret = BitmapFactory.decodeFile(tilePath.getAbsolutePath()); return ret; }
From source file:ca.phon.ipadictionary.impl.TransliterationDictionary.java
private Map<String, String> getTokenMap() { if (tokenMap == null) { try {//from ww w. j a v a2 s . c o m readTokenMap(mapFile.openStream()); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } } return tokenMap; }
From source file:com.yoctopuce.YoctoAPI.YCallbackHub.java
@Override void devRequestAsync(YDevice device, String req_first_line, byte[] req_head_and_body, RequestAsyncResult asyncResult, Object asyncContext) throws YAPI_Exception { try {//from w w w .ja va2 s . c o m cachedRequest(req_first_line, req_head_and_body); } catch (IOException ex) { throw new YAPI_Exception(YAPI.IO_ERROR, ex.getLocalizedMessage()); } }
From source file:com.yoctopuce.YoctoAPI.YCallbackHub.java
@Override byte[] devRequestSync(YDevice device, String req_first_line, byte[] req_head_and_body, RequestProgress progress, Object context) throws YAPI_Exception { try {//from w ww .j a v a2 s. c o m return cachedRequest(req_first_line, req_head_and_body); } catch (IOException ex) { throw new YAPI_Exception(YAPI.IO_ERROR, ex.getLocalizedMessage()); } }
From source file:org.couch4j.DatabaseTest.java
@Test public void testDeleteDatabase() throws Exception { testEmpty.delete();//from www .j a v a 2 s . c o m // Check if the database exists... HttpClient client = new DefaultHttpClient(); // Check if the database exists HttpGet m = null; try { m = new HttpGet(server.toString() + "/" + testEmpty.getName()); HttpResponse response = client.execute(m); assertThat(HttpStatus.SC_NOT_FOUND, is(response.getStatusLine().getStatusCode())); } catch (IOException e) { fail(e.getLocalizedMessage()); } }
From source file:wsattacker.http.transport.SoapHttpClient.java
/** * Sends the SOAP message to the initialized endpoint destination * //from w w w .j a v a2 s. com * @param soap * @return * @throws IOException */ public SoapResponse sendSoap(String soap) throws IOException { final StringEntity httpBody = new StringEntity(soap); post.setEntity(httpBody); int maxTries = MAX_RETRY_NUMBER; HttpResponse httpResponse = null; while (httpResponse == null) { try { httpResponse = client.execute(post); } catch (IOException ex) { if (maxTries == 0) { throw ex; } else { maxTries--; LOG.warn(ex.getLocalizedMessage()); LOG.warn("Trying to send the message once more"); LOG.debug(ex); } } } SoapResponse soapResponse = new SoapResponse(); if (LOG.isDebugEnabled()) { LOG.debug(httpResponse.getStatusLine()); } soapResponse.setStatusLine(httpResponse.getStatusLine().toString()); for (Header h : httpResponse.getAllHeaders()) { final String name = h.getName(); final String value = h.getValue(); if (LOG.isDebugEnabled()) { final String headerDebug = name + ": " + value; LOG.debug(headerDebug); } HttpHeader newHeader = new HttpHeader(name, value); soapResponse.getHeaders().add(newHeader); } LOG.debug("waiting for response: "); final HttpEntity entity = httpResponse.getEntity(); final String charset = EntityUtils.getContentCharSet(entity); final String responseString = EntityUtils.toString(entity, charset); soapResponse.setBody(responseString); return soapResponse; }
From source file:ca.phon.ipadictionary.impl.TransliterationDictionary.java
@Override public String getName() { if (name == null) { try {/* ww w . ja va 2 s . co m*/ readMetadataFromStream(mapFile.openStream()); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } } return name; }
From source file:ca.phon.ipadictionary.impl.TransliterationDictionary.java
@Override public Language getLanguage() { if (language == null) { try {/*from w w w . j av a 2 s . c o m*/ readMetadataFromStream(mapFile.openStream()); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } } return language; }
From source file:com.serotonin.modbus4j.ip.listener.TcpListener.java
@Override synchronized public void destroy() { LOG.debug("Destroy TCPListener Port: " + ipParameters.getPort()); // Close the serverSocket first to prevent new messages. try {/*w w w.j ava2s . c om*/ if (serverSocket != null) serverSocket.close(); } catch (IOException e) { LOG.warn("Error closing socket" + e.getLocalizedMessage()); getExceptionHandler().receivedException(e); } // Close all open connections. if (handler != null) { handler.closeConnection(); } // Terminate Listener terminateListener(); initialized = false; LOG.debug("TCPListener destroyed, Port: " + ipParameters.getPort()); }