Here you can find the source of saveFile(InputStream uploadedInputStream, String serverLocation)
Parameter | Description |
---|---|
uploadedInputStream | a parameter |
serverLocation | a parameter |
public static void saveFile(InputStream uploadedInputStream, String serverLocation)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { /**//from www. j a v a 2s . co m * Save uploaded file to a defined location on the server * @param uploadedInputStream * @param serverLocation */ public static void saveFile(InputStream uploadedInputStream, String serverLocation) { try { OutputStream outpuStream = new FileOutputStream(new File(serverLocation)); int read = 0; byte[] bytes = new byte[1024]; outpuStream = new FileOutputStream(new File(serverLocation)); while ((read = uploadedInputStream.read(bytes)) != -1) { outpuStream.write(bytes, 0, read); } outpuStream.flush(); outpuStream.close(); } catch (IOException e) { e.printStackTrace(); } } }