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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:36:30+00:00 2026-06-16T14:36:30+00:00

I am trying to read a file with doubles. I locate that problem occurs

  • 0

I am trying to read a file with doubles. I locate that problem occurs when I am trying to read decimal numbers. While in case of integers, everything work fine. I am receiving NoSuchElementException exception. Any idea about how to solve my problem? My code:

public class readd {

protected Formatter output;
protected Scanner input = new Scanner(System.in);
private Scanner in = new Scanner(System.in);
protected FileWriter out;
protected BufferedWriter out1;
private String ss;
public int r=1,c=1;
public double[][] output_matrix = null;
public double[][] output_matrix2 = null;
public double[] lap_time = null;

public readd() {
}

public void OpenFileRead(String fileName) {         //anoigma tou arxeiou gia diavasma
    try {
        input = new Scanner(new File(fileName));
        System.out.println(fileName);
    } catch (FileNotFoundException e) {           //sfalma kata tin evresi kai to anoigma tou arxeiou
        System.err.println("Sfalma kata to anoigma toy arxeioy");
        System.exit(0);                          //eksodos
    }
}

public void  Load() {            //anagnwsi dedomenwn apo arxeio

   // double[][] w1 = null;
    int count = 0;
    int row = 0, col = 0;
    // double [][] w1=null;


    try {

        while (input.hasNext()) {       //oso tha iparxei apothikeumeni eggrafi


            count++;
            if (count == 1) {


                row = input.nextInt();
                r = row;
              //  System.out.println(row);
                continue;
            } else if (count == 2) {
                col = input.nextInt();
               // System.out.println(col);
                c = col;
                continue;
            } else {
               //        System.out.println("col="+col);

                output_matrix = new double[row][col];

                for (int i = 0; i < row; i++) {
                    for (int j = 0; j < col; j++) {


                        output_matrix[i][j] = input.nextDouble();

                        //String ss=new Integer(input.nextInt()).toString();
                        //w1[i][j]=Double.parseDouble(ss.trim());

                        // String s1 = new Integer(input.nextInt()).toString();
                        //double v = Double.parseDouble(s1.trim());                                         

                        //String s2 = new Integer(input.nextInt()).toString();
                        //int s = Integer.parseInt(s2.trim());          

                       // System.out.print(output_matrix[i][j]+" ");


                    }
                    // System.out.println(" ");
                }

                //System.out.print(col);
                //System.out.print(row);
            }

        }


    } catch (NoSuchElementException e) {
        System.err.println("Sfalma kata ti tropopoisisi toy arxeioy");
        System.err.println(e.getMessage());       //emfanisi tou minimatos sfalmatos
        input.close();
        System.exit(0);
    } catch (IllegalStateException e) {
        System.err.println("Sfalma kata ti anagnosi toy arxeioy");
        System.exit(0);
    }


}





 }
public static void main(String[] args) {
    // TODO code application logic here
     double[][] wa1;

    readd w = new readd();
    w.OpenFileRead("W1.txt");
    w.Load();
    wa1 = w.output_matrix;
}here
  • 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-16T14:36:31+00:00Added an answer on June 16, 2026 at 2:36 pm

    I’d also like some more information.

    Generally:
    http://docs.oracle.com/javase/1.4.2/docs/api/java/util/NoSuchElementException.html

    It’s the end of an enumerator.

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

Sidebar

Related Questions

In php, I'm trying to read a file that is placed above the web
I'm trying to read some numbers (double) from a file and store them in
Here is my problem, I'm trying to read in data from a file beginningbalance.dat
I am trying to read from a file that has comma seperated values like
Trying to read double data from the file that has different contents. For example
I am trying to read some data from a xml file, numbers are saved
So I am trying to read a csv file that essentially is a list
I'm trying to read a data file (1000 x 5 doubles) into a Mat
I'm trying to write a little program that read from a file. I tryied
I am trying to read file headers using java, I want to get file

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.