1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream stream = p_srcfile.getInputStream();
//----------------------------------------------------------------------
//Generate a unique end file name, using the current date + time
//----------------------------------------------------------------------
String file_end = "";
Calendar cal = Calendar.getInstance(TimeZone.getDefault());
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MM-yy--hh-mm-ss");
sdf.setTimeZone(TimeZone.getDefault());
file_end = sdf.format(cal.getTime());
file_end = "Uploaded_Excel_file" + file_end;
dest_file = p_server_folder + file_end + ".xls";
//--------------------------------------------------------
//write the file to the file specified (on the server!)
//--------------------------------------------------------
System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<< Avant l'ouverture du fichier"+dest_file);
OutputStream bos = new FileOutputStream(dest_file);
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
bos.write(buffer, 0, bytesRead);
}
bos.close();
System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<< après l'ouverture du fichier"); |
Partager