Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- // TODO Auto-generated method stub
- String nomeFileCaricato=request.getParameter("datafile");
- System.out.println("file sorgente:" +nomeFileCaricato);
- String[] file=nomeFileCaricato.split("\\\\");
- String nomefile = null;
- for(int j=0;j<file.length;j++)
- nomefile=file[j];
- boolean risultato;
- try {
- FileInputStream in = new FileInputStream(nomeFileCaricato);
- BufferedInputStream br = new BufferedInputStream(in);
- String path=request.getSession().getServletContext().getRealPath("/");
- path="C:\\Documents and Settings\\Administrator\\Desktop\\"+nomefile;
- System.out.println("file destinazione:" +path);
- File fileDestinazione=new File(path);
- fileDestinazione.createNewFile();
- FileOutputStream out = new FileOutputStream(fileDestinazione);
- BufferedOutputStream bw = new BufferedOutputStream(out);
- int lineaLetta;
- while ( ( (lineaLetta = br.read()) != -1)) {
- //copio nel file di destinazione
- bw.write(lineaLetta);
- }
- br.close();
- bw.close();
- in.close();
- out.close();
- risultato=true;
- }catch(Exception e){
- risultato=false; e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement