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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:45:44+00:00 2026-06-01T16:45:44+00:00

I am trying to output a single string and 2D array into a .txt

  • 0

I am trying to output a single string and 2D array into a .txt file and am running into issues and this is the last part of my project. The program should output a single line, comma-delimited, String, then on the next line, prints out the doubles within the 2D array, comma-delimited. I am suppose to be able to print this all to the .txt file and then open that .txt file in a excel file to graph the information. Here is what I have thus far and I understand there may be more errors than I may see:

 public void writeFile(double[][] array, String filename)
  {
     try{
        File f = new File("output.txt");
        Scanner scan = new Scanner(f);
        scan.useDelimiter("\\s*,\\s*");
        String label = "Algoritm-1, Algorithm-2, Algorithm-3, "
           + "n, n-squared, n-cubed"; //Only one printing of this line

        for (int i = 0; i <= 18; i++)
        {
           for (int j = 0; j <= 5; j++)
           {
              array[i][j] = scan.nextDouble(); //Having the current issue
           }
           scan.nextLine();
        }
     }
        catch (FileNotFoundException fnf) {
           System.out.println(fnf.getMessage());
        }
  }
  • 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-01T16:45:45+00:00Added an answer on June 1, 2026 at 4:45 pm

    It looks like you are using a scanner on your output file. The scanner is generally used to read input files. Open a new output file and print the array to that file.

    Look for an example of OutputStreamWriter. There’s one here:
    http://www.javapractices.com/topic/TopicAction.do?Id=42

    Suggestion: Instead of using 18 and 5 for your loops, can you use the lengths of the array dimensions?

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

Sidebar

Related Questions

I'm trying to load a CSV file into a single dimentional array. I can
I'm trying to output unicode string into RTF format. (using c# and winforms) From
I am trying to parse a string something like this: Input 20:00 - output
I am trying to output a file in perl. I open the file and
I am trying to output results of 2 sql queries to one JSON file.
I'm trying to output each line in a csv file, and it seems like
I'm trying to tar a large directory, and I'd like the output file to
I'm trying to combine multiple JSON objects into a single one in PHP. I'm
After finding the fastest string replace algorithm in this thread , I've been trying
I've got this problem when trying to construct a variable name (which should output

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.