Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is wrong with Java File read?
    primarykey
    data
    text
    <p>I deal with a file problem.</p> <pre><code>IBM 7918 Ayse Durlanik 7600 Computer ------------------------------------ Gama 2342 Mehmet Guzel 8300 Civil ------------------------------------ Lafarge 3242 Ahmet Bilir 4700 Chemical ------------------------------------ Intel 3255 Serhan Atmaca 9200 Electrical ------------------------------------ Bilkent 3452 Fatma Guler 2500 Computer ------------------------------------ Public 1020 Aysen Durmaz 1500 Mechanical ------------------------------------ Havelsan 2454 Sule Dilbaz 2800 Electrical ------------------------------------ Tai 3473 Fethi Oktam 3600 Computer ------------------------------------ Nurol 4973 Ayhan Ak 4100 Civil ------------------------------------ Pfizer 3000 Fusun Ot 2650 Chemical ------------------------------------ </code></pre> <p>This is the text file and I don't want to read this = </p> <pre><code>"------------------------------------ " </code></pre> <p>Here is the method:</p> <pre><code> Scanner scn = null; File fp = new File("C:/Users/Efe/Desktop/engineers.txt"); try { scn = new Scanner(fp); while (scn.hasNextLine()) { { if (!scn.next().equals("------------------------------------")) { String comp = scn.next(); int id = Integer.parseInt(scn.next()); String name = scn.next(); String surname = scn.next(); double sal = Double.parseDouble(scn.next()); String area = scn.next(); Engineer e = new Engineer(comp, id, name, surname, sal, area); list.add(e); } } scn.close(); } </code></pre> <p>This is the code where I get an exception at run-time:</p> <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "Ayse" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) </code></pre> <p>What is wrong with the code?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload