I need to dowload a file .json
from my application, but to choose its location.
I know how to download a file to disk, like for an image
<p:fileDownload value=""/>
public StreamedContent getFile(){ return new DefaultStreamedContent(stream, "image/jpg", "img.jpg"); }
I know how to write to file with
GSON
with given pathtry(JsonWrite j = new JsonWriter(new OutputStreamWriter( new FileOutputStream("C:\\...\\...\\file.json"), "UTF-8"))){ j.beginObject(); // ... j.name("foo"); gson.toJson(myObj, Foo.class, j); //... j.endObject(); }catch(...){...}
But I do not know how to combine both to be able to choose the location and write the json at this location ?