Note that there are some explanatory texts on larger screens.

plurals
  1. POReceiving an error from eclipse when reading a text file
    primarykey
    data
    text
    <p>This is the problem code: if I import the text file at the project level, it gives me this:</p> <pre><code>Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at edu.ilstu.ConcertDriver.main(ConcertDriver.java:59) </code></pre> <p>If I only import the file to a lower directory such as the source folder, it throws the FileNotFoundException. What am I doing wrong?</p> <hr> <p>My file contains the following elements:</p> <p>Maroon 5<br> 15<br> 40<br> One Direction<br> 10<br> 50<br> Pearl Jam<br> 20<br> 30 </p> <p>note that after 30, it returns to the next line</p> <hr> <pre><code>String inputFileName = "concerts.txt"; Scanner inputStream = null; try { inputStream = new Scanner(new File(inputFileName)); } catch(FileNotFoundException e) { System.out.println("Error opening the file " + inputFileName); System.exit(0); } String bandName1=null; int showCapacity1=0; int ticketPrice1=0; String bandName2=null; int showCapacity2=0; int ticketPrice2=0; String bandName3=null; int showCapacity3=0; int ticketPrice3=0; bandName1 = inputStream.nextLine(); showCapacity1 = inputStream.nextInt(); ticketPrice1 = inputStream.nextInt(); bandName2 = inputStream.nextLine(); showCapacity2 = inputStream.nextInt(); ticketPrice2 = inputStream.nextInt(); bandName3 = inputStream.nextLine(); showCapacity3 = inputStream.nextInt(); ticketPrice3 = inputStream.nextInt(); </code></pre>
    singulars
    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.
 

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