List of usage examples for java.io IOException IOException
public IOException(Throwable cause)
From source file:com.liferay.jenkins.tools.ResourceJsonGetter.java
@Override public String getString(String file) throws Exception { URL fileURL = ResourceJsonGetter.class.getResource(file); if (fileURL == null) { throw new IOException(file + " not found"); }/*from w ww . j a v a 2s . c om*/ logger.debug("Retrieving resource from {}", file); return IOUtils.toString(fileURL.openStream(), Charset.defaultCharset()); }
From source file:com.geocent.owf.openlayers.handler.KmzHandler.java
@Override public String handleContent(HttpServletResponse response, InputStream responseStream) throws IOException { ZipInputStream zis = new ZipInputStream(responseStream); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; ZipEntry ze = zis.getNextEntry(); while (ze != null) { if (ze.getName().endsWith("kml")) { int len; while ((len = zis.read(buffer)) > 0) { baos.write(buffer, 0, len); }//from www. j av a 2s . co m response.setContentType(ContentTypes.KML.getContentType()); return new String(baos.toByteArray(), Charset.defaultCharset()); } ze = zis.getNextEntry(); } throw new IOException("Missing KML file entry."); }
From source file:com.github.sdbg.debug.core.internal.sourcemaps.SourceMap.java
public static SourceMap createFrom(File file) throws IOException { String contents = Streams.loadAndClose(new InputStreamReader(new FileInputStream(file), "UTF-8")); try {/* ww w . j a va 2s .c om*/ return createFrom(Path.fromOSString(file.getAbsolutePath()), contents); } catch (JSONException e) { throw new IOException(e); } }
From source file:com.clustercontrol.plugin.ClassUtils.java
/** * ??URLCLASSPATH??<br/>/*w w w . j ava 2s.c om*/ * @param ?URL * @throws IOException */ public static void addURL(URL u) throws IOException { URLClassLoader sysLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); for (URL url : sysLoader.getURLs()) { if (url.toString().equals(u.toString())) { log.info("URL " + u + " is already in CLASSPATH"); return; } } Class<URLClassLoader> sysClass = URLClassLoader.class; try { Method method = sysClass.getDeclaredMethod("addURL", new Class[] { URL.class }); method.setAccessible(true); method.invoke(sysLoader, new Object[] { u }); } catch (Throwable t) { log.warn(t.getMessage(), t); throw new IOException("could not add URL " + u + " to CLASSPATH"); } }
From source file:com.qwazr.utils.process.ProcessUtils.java
public static Boolean isRunning(Number pid) throws IOException, InterruptedException { if (pid == null) return null; final String commandLine; if (SystemUtils.IS_OS_UNIX) commandLine = "kill -0 " + pid; else//from w w w. j a va2 s . c om throw new IOException(NOT_SUPPORTED_ERROR); Integer res = run(commandLine); if (res == null) return null; return res == 0; }
From source file:com.ntsync.android.sync.client.MySSLSocketFactory.java
private static SSLContext createEasySSLContext() throws IOException { try {/*from w ww . ja va 2s . com*/ SSLContext context = SSLContext.getInstance("TLS"); context.init(null, new TrustManager[] { new MyX509TrustManager() }, null); return context; } catch (GeneralSecurityException e) { Log.e(TAG, "Init SSLContext failed.", e); throw new IOException(e.getMessage()); } }
From source file:guru.nidi.ramltester.loader.SimpleUrlFetcher.java
@Override public InputStream fetchFromUrl(CloseableHttpClient client, String base, String name) throws IOException { final HttpGet get = postProcessGet(new HttpGet(base + "/" + encodeUrl(name))); final CloseableHttpResponse getResult = client.execute(get); if (getResult.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { throw new IOException("Http response status not ok: " + getResult.getStatusLine().toString()); }//from w ww.j a v a 2 s . co m return getResult.getEntity().getContent(); }
From source file:guru.nidi.ftpsync.fs.FtpFileSystem.java
public FtpFileSystem(String basedir, Config config) throws IOException { super(basedir); client = new FTPClient(); client.connect(config.getHost());/*from www. jav a 2 s .c o m*/ int reply = client.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { client.disconnect(); throw new IOException("FTP server refused connection."); } final boolean login = client.login(config.getUsername(), config.getPassword()); if (!login) { throw new FtpException("Could not login", client.getReplyStrings()); } client.setFileType(FTP.BINARY_FILE_TYPE); }
From source file:com.rackspacecloud.client.cloudfiles.EasySSLSocketFactory.java
private static SSLContext createEasySSLContext() throws IOException, NoSuchAlgorithmException, KeyStoreException { KeyStore keystore = null;/*w ww .jav a 2 s .c om*/ EasyX509TrustManager extm = new EasyX509TrustManager(keystore); try { SSLContext context = SSLContext.getInstance("TLS"); context.init(null, new TrustManager[] { extm }, null); return context; } catch (Exception e) { throw new IOException(e.getMessage()); } }
From source file:mobi.jenkinsci.ci.client.sso.GitHubSsoHandler.java
@Override public IOException getException(final HttpResponse response) { return new IOException("GitHub Login Failed"); }