2

I try below code to get an URL file's thumbnail.

MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(URL);
byte[] image = mmr.getEmbeddedPicture(); 

I get the byte array(image) of thumbnail. And I want to save it as an image file. How can I do it?

1 Answer 1

16

You can try this.

public void writeToFile(byte[] array) { 
    try { 
        String path = "YOUR_LOCAL_PATH"; 
        FileOutputStream stream = new FileOutputStream(path); 
        stream.write(array); 
    } catch (FileNotFoundException e) { 
        e.printStackTrace(); 
    } 
} 
Sign up to request clarification or add additional context in comments.

2 Comments

Shouldn't it be IOException to catch both FileOutputStream and write()?
@Davidsun whats the file type in PATH?

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.