List of usage examples for java.io InputStream read
public int read(byte b[]) throws IOException
b
. From source file:Main.java
public static void copyAssetFileToFiles(Context context, String root, String filename) throws IOException { InputStream is = context.getAssets().open(filename); byte[] buffer = new byte[is.available()]; is.read(buffer); is.close();/*from ww w . java 2 s.c o m*/ File tgtfile = new File(root + "/" + filename); tgtfile.createNewFile(); tgtfile.setExecutable(true); FileOutputStream os = new FileOutputStream(tgtfile); os.write(buffer); os.close(); }
From source file:Utils.java
/** * Copy in stream to an out stream/*from w w w . j av a2 s . c o m*/ * * @param in * @param out * @throws IOException */ public static void copyInputStream(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[1024]; int len = in.read(buffer); while (len >= 0) { out.write(buffer, 0, len); len = in.read(buffer); } in.close(); out.close(); }
From source file:Main.java
public static void inputToOutput(FileOutputStream outputStream, InputStream inputStream) throws IOException { byte[] buffer = new byte[1024]; int len;/*from w w w .j a va 2s .co m*/ while ((len = inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, len); } outputStream.close(); inputStream.close(); }
From source file:Main.java
public static String AssetJSONFile(String filename, AssetManager manager) throws IOException { String json = null;/*www .j av a2 s.c o m*/ InputStream is = manager.open(filename); int size = is.available(); byte[] buffer = new byte[size]; is.read(buffer); is.close(); json = new String(buffer, "UTF-8"); return json; }
From source file:Main.java
public static void copy(InputStream in, OutputStream out) throws IOException { byte[] buf = new byte[1024]; int len;//from w w w . j a v a 2s.c om while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } }
From source file:Main.java
public static void copy(InputStream in, OutputStream out) throws IOException { byte[] buf = new byte[4096]; int bytes;/*from ww w . j ava2 s . c o m*/ while ((bytes = in.read(buf)) != -1) out.write(buf, 0, bytes); }
From source file:Main.java
public static byte[] readFileFromAsset(String fileName) throws IOException { AssetManager assetMgr = context.getAssets(); InputStream is = assetMgr.open(fileName); int size = is.available(); byte[] content = new byte[size]; is.read(content); is.close();/* ww w . j a v a2s . c o m*/ return content; }
From source file:Main.java
private static void copy(InputStream in, OutputStream out) throws IOException { byte[] b = new byte[2 * 1024]; int read;/*from w ww .j a v a 2 s . c o m*/ while ((read = in.read(b)) != -1) { out.write(b, 0, read); } }
From source file:Main.java
private static void copyFile(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[8192]; int read;/* w w w . ja v a2 s. c o m*/ while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } }
From source file:Main.java
private static void copy(InputStream in, OutputStream out) throws IOException { byte[] b = new byte[1 * 1024]; int read;/*ww w .ja v a 2 s.c om*/ while ((read = in.read(b)) != -1) { out.write(b, 0, read); } }