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…
Something must’ve changed, otherwise it’s magic. Possible suspects: