Hey Guys... im getting an error could you help?
Exception in thread "main" java.lang.NumberFormatException: For input string: "bogus"
at java.lang.NumberFormatException.forInputString(Num berFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.parseInt(Integer.java:499)
at lab10.main(lab10.java:47)
Heres my .txt file
100
200
bogus
300
150
weasel
400
600
250
3.5
800
50
500
450
600
550
import java.util.*; import java.io.*; public class lab10 { public static void main(String [] args) { Scanner inScan; Scanner fScan = null; inScan = new Scanner (System.in); String nextItem; int nextInt = 0; int i = 0; int [] A = new int [5]; boolean check = true; while (check = true){ System.out.println("Please enter the file to read from: "); String fName = inScan.nextLine(); try { fScan = new Scanner (new File(fName)); while (fScan.hasNextLine()) { nextItem = fScan.nextLine(); // Stores first number into nextItem // nextLine READS STRINGS // something going on here.... ^ v reason for this // TAKES String and makes it INT! nextInt = Integer.parseInt(nextItem); A[i] = nextInt; // array i++; // increments the counter // System.out.println( " is not an integer -- ignored"); } System.out.println("Here are your " + i + " items:"); for (int j = 0; j < i; j++) { System.out.println(A[j] + " "); } } catch (FileNotFoundException e) { System.out.println("Your file is invalid "); } }// end while } }