Featured post

Marshmallow Features Point by Point

Android Runtime (“ART”) Improved application performance and lower memory overhead for faster  multi-tasking. Battery Doze...

Showing posts with label Convert_InputStream To File. Show all posts
Showing posts with label Convert_InputStream To File. Show all posts

Monday, 1 February 2016

Stream To File


Call Below Function For Convert.
String Prefix :- "File Name" ex= abc
String Suffix:- "File Tyoe" ex= .xyz

public static File stream2file(InputStream in, String Prefix, String Suffix) throws IOException {
        final File tempFile = File.createTempFile(Prefix, Suffix);
        tempFile.deleteOnExit();
        try (FileOutputStream out = new FileOutputStream(tempFile)) {
            IOUtils.copy(in, out);
        }
        return tempFile;
    }