List of usage examples for java.io IOException IOException
public IOException(Throwable cause)
From source file:mobi.jenkinsci.ci.client.TrustAllSSLSocketFactory.java
private static SSLContext createEasySSLContext() throws IOException { try {//from ww w . jav a2 s .c o m SSLContext context = SSLContext.getInstance("TLS"); context.init(null, new TrustManager[] { new AllowAllX509TrustManager() }, null); return context; } catch (Exception e) { throw new IOException(e.getMessage()); } }
From source file:com.pamarin.api.converter.JsonLocaleDeserializer.java
@Override public Locale deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException { String localeCode = jp.getText(); if (!hasText(localeCode)) { return null; }//from w ww. jav a2 s.c o m String[] split = StringUtils.split(localeCode, "_"); if (split.length != 2) { throw new IOException("not support locale, require language and country"); } if (!hasText(split[0])) { throw new IOException("not support locale, require language"); } if (!hasText(split[1])) { throw new IOException("not support locale, require country"); } return new Locale(split[0], split[1]); }
From source file:Main.java
protected static int deserialiseLength(DataInputStream is, int max_length) throws IOException { int len;//from w ww .j a va 2 s. c om if (max_length < 256) { len = is.readByte() & 0xff; } else if (max_length < 65536) { len = is.readShort() & 0xffff; } else { len = is.readInt(); } if (len > max_length) { throw (new IOException("Invalid DHT data length: max=" + max_length + ",actual=" + len)); } return (len); }
From source file:com.skcraft.launcher.model.minecraft.PlatformDeserializer.java
@Override public Platform deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { String text = jsonParser.getText(); if (text.equalsIgnoreCase("windows")) { return Platform.WINDOWS; } else if (text.equalsIgnoreCase("linux")) { return Platform.LINUX; } else if (text.equalsIgnoreCase("solaris")) { return Platform.SOLARIS; } else if (text.equalsIgnoreCase("osx")) { return Platform.MAC_OS_X; } else {/*from w ww. j av a2s . co m*/ throw new IOException("Unknown platform: " + text); } }
From source file:com.github.khandroid.http.misc.FileDownloader.java
public static byte[] download(HttpClient httpClient, URI source) throws ClientProtocolException, IOException { byte[] ret;/*from w ww. j a v a 2s .c o m*/ KhandroidLog.v("Downloading " + source.toString()); HttpGet req = new HttpGet(source); HttpResponse response = httpClient.execute(req); StatusLine statusLine = response.getStatusLine(); int statusCode = statusLine.getStatusCode(); KhandroidLog.v("Status code:" + statusCode); if (statusCode == 200) { HttpEntity entity = response.getEntity(); ByteArrayOutputStream output = new ByteArrayOutputStream(); entity.writeTo(output); output.close(); ret = output.toByteArray(); } else { throw new IOException( "Download failed, HTTP response code " + statusCode + " - " + statusLine.getReasonPhrase()); } req.releaseConnection(); return ret; }
From source file:com.antosara.akandaka.IO.java
public IO(File db) throws IOException { this.database = db; if (!this.database.exists()) { throw new IOException("File doesn't exist"); }/*from w w w. ja v a2 s . c om*/ }
From source file:Main.java
protected static String getObjectType(Object object) throws IOException { String tagName;/*from ww w .ja va2s. com*/ if (object == null) { tagName = TAG_NULL; } else if (object instanceof String) { tagName = TAG_STRING; } else if (object instanceof Integer) { tagName = TAG_INTEGER; } else if (object instanceof Character) { tagName = TAG_CHARACTER; } else if (object instanceof Double) { tagName = TAG_DOUBLE; } else if (object instanceof Float) { tagName = TAG_FLOAT; } else if (object instanceof Boolean) { tagName = TAG_BOOLEAN; } else if (object instanceof Byte) { tagName = TAG_BYTE; } else if (object instanceof Short) { tagName = TAG_SHORT; } else if (object instanceof Long) { tagName = TAG_LONG; } else if (object instanceof Hashtable) { tagName = TAG_HASHTABLE; } else if (object instanceof Vector) { tagName = TAG_VECTOR; } else if (object instanceof Object[]) { tagName = TAG_ARRAY; } else { // TODO somehow encode it or do something else?? throw new IOException("unknown class: " + object.getClass() + " for object: " + object); } return tagName; }
From source file:org.mcxiaoke.commons.http.ssl.EasySSLSocketFactory.java
private static SSLContext createEasySSLContext() throws IOException { try {/*w ww. j a va2s . c o m*/ SSLContext context = SSLContext.getInstance("TLS"); context.init(null, new TrustManager[] { new TrustAllManager() }, null); return context; } catch (Exception e) { throw new IOException(e.getMessage()); } }
From source file:org.thoughtcrime.securesms.mms.MmsDownloadHelper.java
private static byte[] makeRequest(MmsConnectionParameters connectionParameters, String url) throws ClientProtocolException, IOException { try {//from w w w . j a v a 2 s .c o m HttpClient client = constructHttpClient(connectionParameters); URI hostUrl = new URI(url); HttpHost target = new HttpHost(hostUrl.getHost(), hostUrl.getPort(), HttpHost.DEFAULT_SCHEME_NAME); HttpRequest request = new HttpGet(url); request.setParams(client.getParams()); request.addHeader("Accept", "*/*, application/vnd.wap.mms-message, application/vnd.wap.sic"); HttpResponse response = client.execute(target, request); StatusLine status = response.getStatusLine(); if (status.getStatusCode() != 200) throw new IOException("Non-successful HTTP response: " + status.getReasonPhrase()); return parseResponse(response.getEntity()); } catch (URISyntaxException use) { Log.w("MmsDownlader", use); throw new IOException("Bad URI syntax"); } }
From source file:com.fizzed.stork.launcher.FileUtil.java
static public List<File> findFiles(String fileString, boolean ignoreNonExistent) throws IOException { if (fileString.endsWith("*")) { // file string contains a glob... File f = new File(fileString); File parent = f.getParentFile(); if (parent == null) { parent = new File("."); }// w ww.jav a2 s. co m FileFilter fileFilter = new WildcardFileFilter(f.getName()); File[] files = parent.listFiles(fileFilter); return Arrays.asList(files); } else { File f = new File(fileString); if (!f.exists()) { if (ignoreNonExistent) { return Collections.EMPTY_LIST; } else { throw new IOException("File [" + fileString + "] does not exist"); } } else { if (f.isDirectory()) { return Arrays.asList(f.listFiles()); } else { return Arrays.asList(f); } } } }