All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.openesb.rest.utils.FileUtils Maven / Gradle / Ivy

package net.openesb.rest.utils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 *
 * @author David BRASSELY (brasseld at gmail.com)
 * @author OpenESB Community
 */
public class FileUtils {
    
    // save uploaded file to new location
    public static void writeToFile(InputStream is,
        File newFile) {
 
        try {
            OutputStream out = null;
            int read = 0;
            byte[] bytes = new byte[1024];
 
            out = new FileOutputStream(newFile);
            while ((read = is.read(bytes)) != -1) {
                out.write(bytes, 0, read);
            }
            out.flush();
            out.close();
        } catch (IOException e) {

            e.printStackTrace();
        }
 
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy