Convert Bitmap to File

Hope it will help u: //create a file to write bitmap data File f = new File(context.getCacheDir(), filename); f.createNewFile(); //Convert bitmap to byte array Bitmap bitmap = your bitmap; ByteArrayOutputStream bos = new ByteArrayOutputStream(); bitmap.compress(CompressFormat.PNG, 0 /*ignored for PNG*/, bos); byte[] bitmapdata = bos.toByteArray(); //write the bytes in file FileOutputStream fos = new FileOutputStream(f); fos.write(bitmapdata); … Read more

How to force file download with PHP

Read the docs about built-in PHP function readfile $file_url=”http://www.myremoteserver.com/file.exe”; header(‘Content-Type: application/octet-stream’); header(“Content-Transfer-Encoding: Binary”); header(“Content-disposition: attachment; filename=\”” . basename($file_url) . “\””); readfile($file_url); Also make sure to add proper content type based on your file application/zip, application/pdf etc. – but only if you do not want to trigger the save-as dialog.

Choose File Dialog [closed]

You just need to override onCreateDialog in an Activity. //In an Activity private String[] mFileList; private File mPath = new File(Environment.getExternalStorageDirectory() + “//yourdir//”); private String mChosenFile; private static final String FTYPE = “.txt”; private static final int DIALOG_LOAD_FILE = 1000; private void loadFileList() { try { mPath.mkdirs(); } catch(SecurityException e) { Log.e(TAG, “unable to write … Read more

How can I see local history changes in Visual Studio Code?

Visual Studio Code now offers this in the Timeline view. See Mark’s answer. Or alternatively, if you want a plugin to give you similar functionality, for example: Checkpoints Or the more famous: Local History Some details may need to be configured because the Visual Studio Code search gets confused sometimes because of additional folders created … Read more

What is the perfect counterpart in Python for “while not EOF” [duplicate]

Loop over the file to read lines: with open(‘somefile’) as openfileobject: for line in openfileobject: do_something() File objects are iterable and yield lines until EOF. Using the file object as an iterable uses a buffer to ensure performant reads. You can do the same with the stdin (no need to use raw_input(): import sys for … Read more