M
meghab70
Hi all
I am using java to create a file in directory and after creating i am
using servletOutputStream to display it on web and once it is displayed
I want to delete that file from directory but it is not deleting file.
I am using following code
filePath = "C:/" + fileName;
FileInputStream fis = new FileInputStream(filePath);
int bytesAvailable = fis.available();
byte[] fileBytes = new byte[bytesAvailable];
fis.read(fileBytes);
response.setContentLength(fileBytes.length);
response.setContentType("application/pdf");
ServletOutputStream sos = null;
try
{
sos = response.getOutputStream();
sos.write(fileBytes);
sos.flush();
}
catch (Exception e) {
System.out.println("Exception"+e);
}
finally {
if (sos != null) {
sos.close();
File file = new File(filePath);
System.out.println("filePath"+filePath);
System.out.println("file"+file);
isdeleted = file.delete();
}
Please tell me how I can delete it.
I am using java to create a file in directory and after creating i am
using servletOutputStream to display it on web and once it is displayed
I want to delete that file from directory but it is not deleting file.
I am using following code
filePath = "C:/" + fileName;
FileInputStream fis = new FileInputStream(filePath);
int bytesAvailable = fis.available();
byte[] fileBytes = new byte[bytesAvailable];
fis.read(fileBytes);
response.setContentLength(fileBytes.length);
response.setContentType("application/pdf");
ServletOutputStream sos = null;
try
{
sos = response.getOutputStream();
sos.write(fileBytes);
sos.flush();
}
catch (Exception e) {
System.out.println("Exception"+e);
}
finally {
if (sos != null) {
sos.close();
File file = new File(filePath);
System.out.println("filePath"+filePath);
System.out.println("file"+file);
isdeleted = file.delete();
}
Please tell me how I can delete it.