How to save uploaded file in JSF

The getInputStream() method of the uploaded file represents the file content. InputStream input = uploadedFile.getInputStream(); You need to copy it to a file. You should first prepare a folder on the local disk file system where the uploaded files should be stored. For example, /path/to/uploads (on Windows, that would be on the same disk as … Read more

Save bitmap to location

try (FileOutputStream out = new FileOutputStream(filename)) { bmp.compress(Bitmap.CompressFormat.PNG, 100, out); // bmp is your Bitmap instance // PNG is a lossless format, the compression factor (100) is ignored } catch (IOException e) { e.printStackTrace(); }

Saving an Object (Data persistence)

You could use the pickle module in the standard library. Here’s an elementary application of it to your example: import pickle class Company(object): def __init__(self, name, value): self.name = name self.value = value with open(‘company_data.pkl’, ‘wb’) as outp: company1 = Company(‘banana’, 40) pickle.dump(company1, outp, pickle.HIGHEST_PROTOCOL) company2 = Company(‘spam’, 42) pickle.dump(company2, outp, pickle.HIGHEST_PROTOCOL) del company1 del … Read more

Create and save a file with JavaScript [duplicate]

A very minor improvement of the code by Awesomeness01 (no need for anchor tag) with addition as suggested by trueimage (support for IE): // Function to download data to a file function download(data, filename, type) { var file = new Blob([data], {type: type}); if (window.navigator.msSaveOrOpenBlob) // IE10+ window.navigator.msSaveOrOpenBlob(file, filename); else { // Others var a … Read more