[javaCompiler-users] Error on reading data
Status: Beta
Brought to you by:
soapy
From: <ext...@no...> - 2006-08-25 13:30:30
|
Hello, I have a strange error using a program compiled with Java Compiler. My code is quite easy and it should only read some data from a text file which has two numbers on every line. The java code is: ------------------- import java.io.FileReader; import java.io.BufferedReader; import java.util.StringTokenizer; public class ReadLines { public static void main(String[] args) { double [] realInput =3D new double[new Integer(args[1]).intValue()]; double [] imaginaryInput =3D new double[new Integer(args[1]).intValue()]; =09 // Read the file try { FileReader fr =3D new FileReader(args[0]); BufferedReader bf =3D new BufferedReader(fr); =20 // Read the lines for(int i=3D0;i<new Integer(args[1]).intValue();i++) { // (1) System.out.println("i: " + i); String value =3D new String(); value =3D bf.readLine(); StringTokenizer st =3D new StringTokenizer(value); st.nextToken(); // (2) System.out.println("Reading the value.."); realInput[i] =3D new Double(st.nextToken()).doubleValue(); // (3) System.out.println("Value set: " + realInput[i]); imaginaryInput[i] =3D new Double(0).doubleValue(); // (4) System.out.println("Zero set.."); } bf.close(); fr.close(); } catch(Exception e) { e.printStackTrace(); } } } ------------------- The program can be started with e.g. "ReadLines.exe data.txt 2000" which means "read 2000 lines from data.txt" If I start program from Eclipse, or jar, it works. If I start exe made by JavaCompiler, I receive error message "java.lang.NullPointerException <<No stacktrace available>>", but only if the number of lines is above about 2000. For smaller line numbers it works fine. BUT: if I uncomment the System.out.println - lines (which are numbered in code as (1)-(4)), I receive no error messages and the program works perfectly for line numbers above 2000!! Can you please help me and suggest the solution to this problem? Sincerely yours, Igor Vatolkin PS I'm on vacation from the next Monday so maybe I will read the answer(s) not until the mid of September! |