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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:05:48+00:00 2026-05-15T00:05:48+00:00

I have this code: private static void saveMetricsToCSV(String fileName, double[] metrics) { try {

  • 0

I have this code:

private static void saveMetricsToCSV(String fileName, double[] metrics) {
        try {
            FileWriter fWriter = new FileWriter(
                    System.getProperty("user.dir") + "\\output\\" +
                    fileTimestamp + "_" + fileDBSize + "-" + fileName + ".csv"
            );

            BufferedWriter csvFile = new BufferedWriter(fWriter);

            for(int i = 0; i < 4; i++) {
                for(int j = 0; j < 5; j++) {
                    csvFile.write(String.format("%,10f;", metrics[i+j]));
                }

                csvFile.write(System.getProperty("line.separator"));
            }

            csvFile.close();
        } catch(IOException e) {
            System.out.println(e.getMessage());
        }
    }

But I get this error:

C:\Users\Nazgulled\Documents\Workspace\Só
Amigos\output\1274715228419_5000-List-ImportDatabase.csv
(The system cannot find the path
specified)

Any idea why?

I’m using NetBeans on Windows 7 if it matters…

  • 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-15T00:05:48+00:00Added an answer on May 15, 2026 at 12:05 am

    In general, a non existent file will be created by Java only if the parent directory exists.
    You should check/create the directory tree:

      String filenameFullNoPath = fileTimestamp + "_"  + fileDBSize + "-" 
            + fileName + ".csv";
      File myFile =  new File(System.getProperty("user.dir")  + File.separator 
            + "output" + File.separator + filenameFullNoPath);
      File parentDir = myFile.getParentFile();
      if(! parentDir.exists()) 
          parentDir.mkdirs(); // create parent dir and ancestors if necessary
      // FileWriter does not allow to specify charset, better use this:
      Writer w = new OutputStreamWriter(new FileOutputStream(myFile),charset);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 491k
  • Answers 491k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Consider ordering by the DateSubmitted on the return of the… May 16, 2026 at 10:04 am
  • Editorial Team
    Editorial Team added an answer I see no problem with your extension. If it works… May 16, 2026 at 10:04 am
  • Editorial Team
    Editorial Team added an answer The method android uses to create the tween animation is… May 16, 2026 at 10:04 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have this code... internal static void Start() { TcpListener listenerSocket = new TcpListener(IPAddress.Any,
I have this piece of code in c#: private static void _constructRow(SqlDataReader reader, system.IO.StreamWriter
I have this code in my C# project: public void startRecognition(string pName) { presentationName
I have this code: 001 private void uiButton1_Click(object sender, EventArgs e) 002 { 003
I have written this code but it will print these stack traces in the
I have a class namespace LogToolsTest { public class Foo { private static readonly
Related: How do I create a static local variable in Java? Pardon if this
Please help me out with this. I have this small application to load txt
I have these two pieces of code that could possibly be run at the
I am referring to this code example, which is being reported in https://bugs.java.com/bugdatabase/view_bug?bug_id=6254531 import

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.