Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8189929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:26:54+00:00 2026-06-07T03:26:54+00:00

I am using icefaces to upload files to relative path in my web app

  • 0

I am using icefaces to upload files to relative path in my web app (mywebapp/audio), then after the file is getting uploaded I rename it to save its extension as follows:

public static File changeExtToWav(FileInfo fileInfo,
            StringBuffer originalFileName) {
        log.debug("changeExtToWav");
        int mid = fileInfo.getFile().getName().lastIndexOf(".");
        String fileName = fileInfo.getFile().getName().substring(0, mid);
        originalFileName.append(fileName);
        log.debug("originalFileName: " + originalFileName);
        String newFileName = fileName + "_" + new Date().getTime() + "."
                + "wav";
        File newFile = new File(fileInfo.getFile().getParent() + "/"
                + newFileName);
        log.debug("newFileName: " + newFile.getName());
        fileInfo.getFile().renameTo(newFile);
        return newFile;
    }

after the file is getting uploaded, sometimes I want to delete it from UI button as follows:

try {

            File fileToDelete = new File(filePath); // correct file path
            log.debug("file exists: " + fileToDelete.exists()); // true
            fileToDelete.delete();
        } catch (Exception e) {
            e.printStackTrace();
        }

the file path is correct, and I get no exceptions, but the file is not deleted (I am using java 6 btw).
please advise how to fix this issue.

UPDATE: using the following useful method, I can get that the file is opened, any ideas how to close it ?

public String getReasonForFileDeletionFailureInPlainEnglish(File file) {
    try {
        if (!file.exists())
            return "It doesn't exist in the first place.";
        else if (file.isDirectory() && file.list().length > 0)
            return "It's a directory and it's not empty.";
        else
            return "Somebody else has it open, we don't have write permissions, or somebody stole my disk.";
    } catch (SecurityException e) {
        return "We're sandboxed and don't have filesystem access.";
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:26:55+00:00Added an answer on June 7, 2026 at 3:26 am

    Well if the file is open, then there is two solutions :

    • You have a stream in your program open on this file. Note that afaik it’s a problem on Windows, with Unix I can delete a File even if a stream is opened on it.

    • You have an other process using this file. So in this case you can’t do anything from Java.

    In the log it tells also that it can be a permission problem, are you sure you have enough privileges?

    You can also use Files#delete(Path path) (jdk7) to have more details about the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a JSF and Hibernate web app with ICEfaces. I am
I have a small web application developed using Icefaces 1.8.2 and jsf 1.1 which
I am using Icefaces for webapplication development. I wish to read a file from
Im getting this exception when the view try to renders, im using the icefaces
I am using icefaces, ace:fileEntry component for uploading files from client and those files
I have an ICEfaces web app which contains a component with a property linked
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
i am using icefaces select on menu to select a user from list of
I have a JSF 1.2 dataTable using ICEfaces 1.8. In one column, I would
While evaluating ICEfaces I have used Eclipse and its Web Page Editor to visually

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.