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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:59:48+00:00 2026-05-25T13:59:48+00:00

i am trying to create a text file in a folder (called AMCData). The

  • 0

i am trying to create a text file in a folder (called AMCData). The file is called “File” (for the sake of this example).

I have tried using this code:

public static void OpenFile(String filename)
{
    try
    {
        f = new Formatter("AMCData/" + filename + ".txt");          
    }
    catch(Exception e)
    {
        System.out.println("error present");
    }
}

But before i get the chance to even place any text in it, the catch keeps being triggered..
Could anyone inform me why this is occuring?

more information:

  • The folder does not exist, i was hoping it would automatically create it
  • If it doesn’t automatically create folders, could you please link me to how to do so?
  • 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-05-25T13:59:48+00:00Added an answer on May 25, 2026 at 1:59 pm

    You’re right, a Formatter(String) constructor needs the file to be present or createable. The most likely reason why a file cannot be created is that it references a folder that itself doesn’t exist, so you should use the File.mkdirs() method, like this:

    new File("AMCData").mkdirs();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a text file using VB.Net with UTF8 encoding, without
I'm trying to create a program that takes a text file of c++ code
Using VB.NET, I am trying to create a text file if it doesn't exist
I am trying to create PDF file using DOM pdf and Codeigniter. I have
I'm trying to create a layout similar to this: alt text http://img20.imageshack.us/img20/3533/stackn.png Here's the
There is a text file that I have created in my project root folder.
I am trying to create a text file with PHP in fopen(test.txt,a) . I
I'm trying to create a temporary text file in C++ and then delete it
I am trying to check if file doesn't have anything in it. This is
I'm trying to create a text file in my Windows Forms application. It is

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.