NumberFormatException in Stars.java -


I am working on it for a while and I keep getting a single error.

Exception in thread "main" java.lang.NumberFormatException: for input string: "java.lang.NumberFormatException.forInputString (numberFormatException.java:65) on java.lang.Integer.parseInt (Integer.java:504) in the Stars table in the Stars table.adray (stars table.javaedit) java.lang.Integer.valueOf (integer.jpg 82). & Lt; init & gt; (Stars Table.Java 24) Stars in the public. Stars (public jargon main) (String AGR []) {String infix = Args [0];

Stars Ebay stars = new star tables (infile); line 7 system.out.println ("program to output a star map."); System.out.println ("written by"); Println (stars.title () ); Integer [] [] a = stars.getArray (); for system.out.print ("-"); (int x = 0; x & lt; a.length; x ++) System.out For print ("-"); (int i = 0; i a [0]; length; i ++) {System.out.print ("\ n:"); For (int j = 0; J & LT; A Long; J ++) {if (stars. Check East Starter (I, J) == 1) {System.out.print ("*"); } Else System.out.print (""); }}}

}

StarsTable.java

  import java.io.buffferedReader; Import java.io.fileReader; Import java.io.IOException; Import java.util. *; Public category stars table {Private Archieist & Lt; Integer & gt; A = New Arrestist & lt; Integer & gt; (); Private string title; Private string readLine = null; Private int rows = 0; Private integer array [] []; Public Stars Table (String Filename) {try {BufferedReader br = new BufferedReader (New FileReader (fileName)); Title = br.readLine (); While ((readLine = br.readline ()) = = null {addArray (readLine); Line 24} br.close (); } Hold (IOException e) {System.err.println ("File not found" "Enter the file name in the command line."); System.exit (1); }} Public String Title () {Return Title; } Public Zero addArray (string readline) {int i = 0; String [] splitLine = readLine.split (""); (I = 0; i & lt; splitLine.length; i ++) for {a.add (integer.valof (partition lin [i])); Line 50} rows ++; } Public Integer [] [] getArray () {toArray (); Return array; } Public from zero () {array = new integer [a.size ()) / rows [rows]; int g = 0; (Et i = 0; i & lt; (a.size () / rows); i ++) {for (int k = 0; k & lt; rows; k ++) {array [i] [k] = A.get (g); G ++; }}} Public At Czech IfStar (int i, int k) {integer check = 0; // Corner if (I == 0 & amp; amp; k == 0) check = array [i] [k] + array [i + 1] [k] + array [i] [k + 1] ; Else if (i == array [0] length and amp; k == 0) check = array [i] [k] + array [i - 1] [k] + array [i] [k-1 ]; Else if (i == 0 & amp; amp; amp; k == array.length) check = array [i] [k] + array [i] [k - 1] + array [i + 1] [k] ; Else if (i == array [0]. Length and a == array.length) check = array [i] [k] + array [i] [k - 1] + array [i - 1] [k] ]; // edges and if (i = 1) // top check = array [i] [k] + array [i] [k + 1] + array [i - 1] [k] + array [i + 1] [ K]; Array [i] [k - 1] + array [i] [k + 1] + array [i + 1] [k]; Else if (i == array [0] .length) // right check = array [i] [k] + array [i] [k - 1] + array [i] [k + 1] + array [i - 1] [K]; Other if (k == array.length) // bit check = array [i] [k] + array [i] [k - 1] + array [i - 1] [k] + array [i + 1] [ K]; Array [i - 1] [a] + array [i + 1] = [sir] [a] of [array] array [i] [k - 1] + array [i] [k + 1] [k]; Check = check / 5; If (check & lt; 5) return 0; Other return 1; }}   

I can not understand what is the problem in his life. Any help would be greatly appreciated. Thanks!

Try changing the code like this,

  For (I = 0; i & lt; splitLine.length; i ++) {a.add (integer.valof (split line) .tim ())); }   

for

  (i = 0; i & lt; splitLine.length; i ++) {try {a.add ( integer.valueOf (splitLine [i] .trim ())); } Catch (NumberFormat Exstation) {System.out.println ("The exception is:" + split line [i]); }}    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -