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 8286957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:54:43+00:00 2026-06-08T11:54:43+00:00

In my jUnit , i have a following snippet: private String session = /tmp/session/;

  • 0

In my jUnit, i have a following snippet:

private String  session = "/tmp/session/";
private File    f;

@Before
public void setUp() {
    f = new File(session);
    f.mkdir();
}

@After
public void tearDown() {
    System.out.println("Directory deleted:   " + f.delete()); // always false
}

Meanwhile:

  • Directory permissions are ok (drwxr-xr-x)
  • Directory contains some files (-rw-r--r--)
  • No ownership issues (Creator user deletes)

What would cause for f.delete() to fail? Is f.delete() an equivalent of rm -rf ?

  • 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-08T11:54:44+00:00Added an answer on June 8, 2026 at 11:54 am

    From the API documentation for File.delete:

    delete
    
    public boolean delete()
    Deletes the file or directory denoted by this abstract pathname. If this pathname
    denotes a directory, then the directory must be empty in order to be deleted.
    Returns:
    true if and only if the file or directory is successfully deleted; false otherwise
    Throws:
    SecurityException - If a security manager exists and its SecurityManager.checkDelete(java.lang.String) method denies delete
    

    access to the file

    Note the bit about the directory needing to be empty.

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

Sidebar

Related Questions

I am new to junit testing and I have the following test - public
I have the following JUnit test: @Test public void testRunLocalhost() throws IOException, InterruptedException {
I have a property file with the following junit.version=3.8.1 dbcp.version=5.5.27 oracle.jdbc.version=10.2.0.2.0 I try to
I have the following snippet of java code: final Class<?> junitCoreClass = AccessController.doPrivileged( new
I am new to Java and junit. I have the following peice of code
I have the following build.xml file setup in phpUnderControl. <target name=phpunit> <exec executable=phpunit dir=${basedir}/httpdocs
I have an Ant file contains a Junit target, before running the Junit target
I have the following expectation in a JUnit test class: CustomEvent myCustomEvent = new
I have the following tasks in ant: <target name=init-junit depends=init> <mkdir dir=${junit.reports.individual} /> <property
I have the following string: public static final String UPDATESONG = update songs SET

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.