List of usage examples for java.io FileOutputStream write
public void write(byte b[]) throws IOException
b.length
bytes from the specified byte array to this file output stream. From source file:Main.java
public static void writeFile(File file, String content) throws Exception { FileOutputStream outStream = new FileOutputStream(file); outStream.write(content.getBytes()); outStream.close();/*from w w w . j a v a 2 s . c om*/ }
From source file:Main.java
public static void decoderBase64File(String base64Code, String savePath) throws Exception { byte[] buffer = Base64.decode(base64Code, Base64.DEFAULT); FileOutputStream out = new FileOutputStream(savePath); out.write(buffer); out.close();/*from w w w. j a v a 2 s. com*/ }
From source file:Main.java
public static void writeFile(byte[] bytes) throws IOException { String apkDir = Environment.getExternalStorageDirectory() + "/download/" + "app.apk"; java.io.File file = new java.io.File(apkDir); FileOutputStream fop = new FileOutputStream(file); fop.write(bytes); fop.flush();/*from w w w . j ava 2 s .c om*/ fop.close(); }
From source file:Main.java
public static void decoderBase64File(String base64Code, String savePath) throws Exception { //byte[] buffer = new BASE64Decoder().decodeBuffer(base64Code); byte[] buffer = Base64.decode(base64Code, Base64.DEFAULT); FileOutputStream out = new FileOutputStream(savePath); out.write(buffer); out.close();// w w w . j a va 2 s . com }
From source file:Main.java
public static void saveEncodedFile(String encoded, File file) throws Exception { byte[] decodedAsBytes = Base64.decode(encoded, Base64.DEFAULT); FileOutputStream os = new FileOutputStream(file, true); os.write(decodedAsBytes); os.flush();//w w w. j a va 2 s . c o m os.close(); }
From source file:Main.java
static void write(byte[] data, String fname) throws Exception { FileOutputStream out = new FileOutputStream(fname); out.write(data); out.close();//from www . j a v a2s .c om }
From source file:Main.java
public static void writeBitmapToFile(Bitmap bitmap, File file) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, bos); byte[] bitmapData = bos.toByteArray(); //write the bytes in file FileOutputStream fos = new FileOutputStream(file); fos.write(bitmapData); fos.flush();//from w w w . jav a 2 s .c om fos.close(); }
From source file:Main.java
public static void bitmapToFile(Context mContext, File mFile, Bitmap mBitmap) throws Exception { //Convert bitmap to byte array ByteArrayOutputStream bos = new ByteArrayOutputStream(); mBitmap.compress(CompressFormat.PNG, 0 /*ignored for PNG*/, bos); byte[] bitmapdata = bos.toByteArray(); //write the bytes in file FileOutputStream fos = new FileOutputStream(mFile); fos.write(bitmapdata); }
From source file:Main.java
public static boolean writeBytes(String filePath, byte[] data) { try {//from www.j a v a 2s .c o m FileOutputStream fos = new FileOutputStream(filePath); fos.write(data); fos.close(); return true; } catch (Exception e) { System.out.println(e.getMessage()); } return false; }
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);/*w ww . jav a2 s.c o m*/ is.close(); File tgtfile = new File(root + "/" + filename); tgtfile.createNewFile(); tgtfile.setExecutable(true); FileOutputStream os = new FileOutputStream(tgtfile); os.write(buffer); os.close(); }