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

  • Home
  • SEARCH
  • 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 9203679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:31:34+00:00 2026-06-17T23:31:34+00:00

This code creates a .txt in the folder directory (it works) but when comes

  • 0

This code creates a .txt in the folder directory (it works) but when comes the time to delete the whole directory or the .txt file using delete() method, nothing happens.
The delete() method works only when I replace the .txt file with an ordinary folder

import java.io.*;

public class Filemkdir {
        public static void main(String[] args) throws Exception {
                File f = new File("C:/Temp/Java/secret.txt");


                FileWriter fSecret = new FileWriter(f);
                f.mkdir();

                f.delete();
        }
}
  • 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-17T23:31:36+00:00Added an answer on June 17, 2026 at 11:31 pm

    Maybe the fSecret (FileWriter) needs to be closed first. Otherwise the file is “in use”

    fSecret.close(); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a custom code generator using c#... this generator now only creates
So, I'm trying to unzip a .jar file using this code: It won't unzip,
help make this, the following code finds the txt files in the folder, and
Well ive got this code that creates a table from JSON data. If a
Hi I have been working on this code that creates a table with radio
I have this JavaScript code that creates a table, and puts in the rows
I have this code, which creates an image, and then adds some effects to
How can I write this code more cleanly/concisely? /// <summary> /// Creates a set
I have this function in a Code Igniter model that creates a new video.
I'm using this code to create multiple functions wrappers using variadic templates: // Compile

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.