List of usage examples for java.io InputStream close
public void close() throws IOException
From source file:Main.java
public static boolean settingsExist() throws IOException { try {/* w ww . j ava 2 s . c o m*/ InputStream in = new FileInputStream("data/data/com.junk.settings/shared_prefs/Junk_Settings.xml"); if (in != null) { in.close(); } } catch (IOException ex) { return false; } return true; }
From source file:Main.java
/** * Parses XML from an input stream./*from ww w . ja va 2s . c om*/ * * @param stream Input stream containing valid XML. * @return XML document. * @throws Exception Unspecified exception. */ public static Document parseXMLFromStream(InputStream stream) throws Exception { Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(stream); stream.close(); return document; }
From source file:Main.java
public static boolean themeTwoExist() throws IOException { try {/*from w w w . j a va 2 s . co m*/ InputStream in = new FileInputStream("data/data/com.junk.settings/shared_prefs/Junk_Theme_Two.xml"); if (in != null) { in.close(); } } catch (IOException ex) { return false; } return true; }
From source file:Main.java
static Bitmap createBitmap(String src) throws IOException { if (src == null || src.length() == 0) { // no image source defined return null; }/* w ww .j a v a 2s . co m*/ InputStream inputStream = createInputStream(src); Bitmap bitmap = BitmapFactory.decodeStream(inputStream); inputStream.close(); return bitmap; }
From source file:Main.java
public static boolean themeOneExist() throws IOException { try {//ww w . ja v a2s . c o m InputStream in = new FileInputStream("data/data/com.junk.settings/shared_prefs/Junk_Theme_One.xml"); if (in != null) { in.close(); } } catch (IOException ex) { return false; } return true; }
From source file:com.bt.aloha.batchtest.WeekendBatchTest.java
protected static void addBatchScenarios(BatchTest batchTest) throws Exception { Properties properties = new Properties(); InputStream is = new FileInputStream(SCENARIO_FILE); properties.load(is);/*from w ww . ja va 2 s. co m*/ is.close(); for (Object scenarioName : properties.keySet()) { String name = (String) scenarioName; String value = properties.getProperty(name); batchTest.addBatchTestScenario(name + "," + value); } }
From source file:Main.java
public static String getStringFromConnection(HttpURLConnection connection) throws IOException { InputStream inputStream = new BufferedInputStream(connection.getInputStream()); String jsonString = convertStreamToString(inputStream); inputStream.close(); return jsonString; }
From source file:Main.java
public static boolean themeThreeExist() throws IOException { try {//from www .ja v a 2s.com InputStream in = new FileInputStream("data/data/com.junk.settings/shared_prefs/Junk_Theme_Three.xml"); if (in != null) { in.close(); } } catch (IOException ex) { return false; } return true; }
From source file:mx.bigdata.cfdi.security.KeyLoader.java
private static byte[] getBytes(InputStream in) throws Exception { try {/*from w w w. ja v a 2 s. c o m*/ return ByteStreams.toByteArray(in); } finally { in.close(); } }
From source file:Main.java
public static BitmapDrawable getBitmapDrawableRes(Context context, int resId) { BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inPreferredConfig = Bitmap.Config.RGB_565; opt.inPurgeable = true;// w w w . j a va 2 s . c om opt.inInputShareable = true; InputStream is = context.getResources().openRawResource(resId); Bitmap bitmap = BitmapFactory.decodeStream(is, null, opt); try { is.close(); } catch (IOException e) { e.printStackTrace(); } return new BitmapDrawable(context.getResources(), bitmap); }