1

Please tell me how set saving path for downloading file.

For example:

AsyncHttpClient client = new AsyncHttpClient();
String[] allowedTypes = new String[] { "image/png" };
client.get("http://www.example.com/image.png", new BinaryHttpResponseHandler(allowedTypes) {
    @Override
    public void onSuccess(byte[] imageData) {
        // Successfully got a response
    }

    @Override
    public void onFailure(Throwable e, byte[] imageData) {
        // Response failed :(
    }
 });
2
  • 1
    Very Short Explanation. Try to be brief about issue Commented Dec 4, 2013 at 11:25
  • This the question of the use of lib loopj. In particular, how to set a path for the file to be loaded. Mr. Aamirkhan I'm sorry if the question is not clear why put a minus Commented Dec 4, 2013 at 11:38

1 Answer 1

3

You need use this byte array with an OutputStream subclass to write the bytes on disc,

OutputStream f = new FileOutputStream(new File("path"));
f.write(bytes); //your bytes
f.close();

This code will write the file on disk, to get the path maintain the File on a variable and use File.getAbsolutePath()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.