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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:04:17+00:00 2026-05-20T01:04:17+00:00

I have a text file where first two lines are integers m and n

  • 0

I have a text file where first two lines are integers m and n, then there are m lines that each has n pipe-delimited values. I wrote a program that reads the file and creates m*n array with the values from the file, and it worked fine for bajillion times, and then out of sudden, with the same code, with the same file, it threw NumberFormatException while reading the integer from the first line. The whole code is here:

public class Thegame extends JFrame {
    public Integer st;
    public Integer el;
    public String[][] tab;

    public Thegame(String pth)
    {
        setSize(640,480);
        setTitle(pth);
        File file = new File(pth);
        try
        {
            BufferedReader rdr = new BufferedReader(new FileReader(file));
            st = Integer.valueOf(rdr.readLine());
            el = Integer.valueOf(rdr.readLine());
            tab = new String[st][el];
            for(Integer i=0; i<st; i++)
            {
                String lin = rdr.readLine();
                StringTokenizer spl = new StringTokenizer(lin,"|");
                for(Integer j=0; j<el; j++)
                {
                    tab[i][j] = spl.nextToken();
                }                
            }
            rdr.close();            
        }
        catch(Exception ex)
        {
            JOptionPane.showMessageDialog(null, ex);
        }
    }
}

What really worries me is that the same code worked okay before and out of nowhere it turned out to be bad, so I can’t even tell what exactly is wrong…

  • 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-20T01:04:18+00:00Added an answer on May 20, 2026 at 1:04 am

    Something must’ve changed, otherwise it’s magic. Possible suspects:

    • the content of the input file has changed. Have you checked it with some kind of hex editor. Does the file start with digits indeed?
    • Java/system locale have changed. What previously was treated as a number, no longer is a number in the new locale. Typical catches with locale are thousands separators (,).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays built while parsing a text file. The first contains the
I have two lines in a text file like below: S<Switch_ID>_F<File type> _ID<ID number>_T<date+time>_O<Original
Say I have a file, t.txt, that contains the following two lines: one two
I have a large text file of records, each delimited by a newline. Each
I have a text file where I want to change only the first line
I have a text file on my local machine that is generated by a
I have a text file that contains a long list of entries (one on
I have a text file that contains localized language strings that is currently encoded
I have a text file that is encoded in UTF-8. I'm reading it in
Say I have the following style of lines in a text file: 12 34

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.