jeudi 26 décembre 2019

java -java.nio.file.FileSystemException The process cannot access the file because it is being used by another process

 //for Image1
    Part part = request.getPart("pimage1");
    String fileNameAbsolute = extractFileName(part);
    String fileName= extractFileNameEnd(fileNameAbsolute);
    String savePath ="E:\\ecom2\\WebContent\\images\\" + File.separator + fileName ;
    System.out.println("filename is:"+fileName);
    String origPath="E:\\ecom2\\WebContent\\imageforE\\" + File.separator + fileName ;
  //String origPath="E:\\images\\"+ File.separator + fileName ;

    Path temp = Files.move 
            (Paths.get(origPath),  
            Paths.get(savePath));
    if(temp != null)  { out.println("File renamed and moved successfully"); } 
    else    { out.println("Failed to move the file");  } 

line 5 is printing correctly but after that path temp is not working , error is there the process cant access the file. how to close part object.




Aucun commentaire:

Enregistrer un commentaire