Upload: First get upload path + file name, then upload
Download:
1. Read the files under the server path (i.e. files that need to be downloaded) to know
--File path + file name, using input stream FileInputStream to read the file into buffer
2. Create an output stream OutputStream to write buffer data to the output stream
--Output stream required--Output path + file name
File2 =e:/download/filetest/file7.txt
OutputStream OS = new FileOutputStream (file2);
3. If you do not specify a specific output path, directly using response to create the output stream, the default download to the browser corresponding to the path
OutputStream OS = Response.getoutputstream ();
4. File Upload to relative path
Path after file upload, relative path
String filePath1 = Request.getsession (). Getservletcontext (). Getrealpath ("/upload/test/");
The path of the file is--\src\main\webapp\upload\test after the upload is successful---
Absolute path
String filepath1= "c://users//andrew//desktop//filetest//";
5. File download from a relative path
String Realpath = Request.getservletcontext (). Getrealpath ("/upload/test/");
--the relative path is relative----\src\main\webapp
File upload and download problem record