List of usage examples for java.io IOException getMessage
public String getMessage()
From source file:ConsoleInput.java
public static String readLine() { StringBuffer response = new StringBuffer(); try {/* w w w .jav a2 s. c om*/ BufferedInputStream buff = new BufferedInputStream(System.in); int in = 0; char inChar; do { in = buff.read(); inChar = (char) in; if ((in != -1) & (in != '\n') & (in != '\r')) { response.append(inChar); } } while ((in != -1) & (inChar != '\n') & (in != '\r')); buff.close(); return response.toString(); } catch (IOException e) { System.out.println("Exception: " + e.getMessage()); return null; } }
From source file:Main.java
public static Bitmap getEmotion(Context context, String key) { String fileName = "default_emotions_package/" + MAP.get(key); try {//from www . j av a 2 s. co m AssetManager am = context.getAssets(); return BitmapFactory.decodeStream(am.open(fileName)); } catch (IOException e) { Log.e(TAG, e.getMessage()); } return null; }
From source file:Main.java
public static String loadAssetsText(AssetManager assetManager, String fileName, String charset) { String text = null;// w w w . jav a 2s.c o m try { BufferedReader br = new BufferedReader(new InputStreamReader(assetManager.open(fileName), charset)); StringBuilder sb = new StringBuilder(); while ((text = br.readLine()) != null) { sb.append(text); } text = sb.toString(); } catch (IOException e) { Log.e(TAG, e.getMessage(), e); } return text; }
From source file:Main.java
public static void close(Closeable c) { if (c != null) { try {// w ww. ja v a 2 s . c om c.close(); } catch (IOException ex) { Log.d("Trouble closing connection", ex.getMessage()); } } }
From source file:it.marcoberri.mbfasturl.utils.HttpUtil.java
/** * /*from w ww. j av a 2s .c o m*/ * @param url * @param target */ public static synchronized void downloadData(String url, String target) { try { org.apache.commons.io.FileUtils.copyURLToFile(new URL(url), new File(target)); } catch (IOException ex) { System.err.println(ex.getMessage()); } }
From source file:Main.java
public static int numberBounce(PrintWriter out, BufferedReader in) { try {/* ww w. j a v a 2 s.c om*/ String theString = in.readLine(); if (theString != null) { int num = Integer.parseInt(theString); ++num; out.println("" + num); return num; } } catch (IOException e) { Log.e("NUMBER_BOUNCE_METHOD", e.getMessage()); } return -1; }
From source file:dev.argent.hive.SqlScriptLoader.java
@SuppressWarnings("unchecked") public static String[] getScripts(Class<?> clazz, String sqlFileName) { try {//from w w w .ja v a2 s.com String fileName = clazz.getResource(sqlFileName).getFile(); String comments = stripComments((List<String>) FileUtils.readLines(new File(fileName))); return StringUtils.delimitedListToStringArray(comments, ";"); } catch (IOException e) { log.warn(e.getMessage(), e); throw new IllegalArgumentException("SqlFile load failed. fileName : " + sqlFileName, e); } }
From source file:Main.java
private static String readTextFile(InputStream inputStream) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); byte buf[] = new byte[1024]; int len;//from w ww.j ava 2 s. co m try { while ((len = inputStream.read(buf)) != -1) { outputStream.write(buf, 0, len); } outputStream.close(); inputStream.close(); } catch (IOException e) { Log.i("IO error", e.getMessage()); return "Sorry, help file not found."; } return outputStream.toString(); }
From source file:Main.java
public static String loadJSONFromAsset(Context context, String fileName) { String json = null;/*w w w . j av a2 s. c om*/ try { InputStream is = context.getAssets().open(fileName); int size = is.available(); byte[] buffer = new byte[size]; is.read(buffer); is.close(); json = new String(buffer, "UTF-8"); } catch (IOException ex) { Log.d(TAG, "Exception Occurred : " + ex.getMessage()); return null; } return json; }
From source file:it.marcoberri.mbmeteo.utils.HttpUtil.java
/** * * @param url/*from ww w . ja v a 2s . com*/ * @param target */ public static synchronized void downloadData(String url, String target) { try { org.apache.commons.io.FileUtils.copyURLToFile(new URL(url), new File(target)); } catch (IOException ex) { System.err.println("errore " + ex.getMessage()); } }