Extracting data elements from a text file
<p>I'm making an application that organizes world of warcraft jewel crafting auction data by the most valuable gems of each color. To do this I'm attempting to parse a json database to an array -- I know it would be simple to just us something like the gson api to do this but since this is a project for an entry level java class my professor has stated that I should use things we learned in class to import data, with that being said I've got the following code to parse json data and print it on screen (still working on parsing to an array) <a href="https://www.dropbox.com/s/oh7wahmcktkpuyv/data.json" rel="nofollow">I've uploaded my data.json to here</a> and included the code I have so far below:</p>

<pre><code>import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class jcFormat {

public static void main(String[] args) {
    try {
        File f = new File("c:\\ProgramData\\jcUtil\\data.json");
        Scanner sc = new Scanner(f);

        List&lt;Auction&gt; ahdata = new ArrayList&lt;Auction&gt;();
        sc.nextLine();//eats line
        sc.nextLine();//eats line
        sc.nextLine();//eats line
        while (sc.hasNextLine()) {
            String line = sc.nextLine();
            String[] details = line.split(",");
            //get item as string
            String itemz = details[1];
            itemz = itemz.substring(7, itemz.length());
            //convert itemz string to item int
            int item = Integer.parseInt(itemz);
            //get buyout as string
            String buyoutz = details[4];
            buyoutz = buyoutz.substring(9, buyoutz.length());
            //convert buyoutz string to buyout int
            int buyout = Integer.parseInt(buyoutz);
            //get quantity as string
            String quantityz = details[5];
            quantityz = quantityz.substring(11, quantityz.length());
            //convert quantityz string to quantity int
            int quantity = Integer.parseInt(quantityz);

            Auction a = new Auction(item, buyout, quantity);
            ahdata.add(a);
        }

        for (Auction a : ahdata) {
            System.out.println(a.toString());
        }

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}
}

class Auction {

private int item;
private int buyout;
private int quantity;

public Auction(int item, int buyout, int quantity) {
    this.item = item;
    this.buyout = buyout;
    this.quantity = quantity;
}

/**
 * @return the item
 */
public int getItem() {
    return item;
}

/**
 * @param item the item to set
 */
public void setItem(int item) {
    this.item = item;
}

/**
 * @param buyout the buyout to set
 */
public void setBuyout(int buyout) {
    this.buyout = buyout;
}

/**
 * @return the buyout
 */
public int getBuyout() {
    return buyout;
}

/**
 * @return the quantity
 */
public int getQuantity() {
    return quantity;
}

/**
 * @param quantity the quantity to set
 */
public void setQuantity(int quantity) {
    this.quantity = quantity;
}

@Override
public String toString() {
    return this.item + "\t" + this.buyout + "\t" + this.quantity;
}
}
</code></pre>

<p>The issue I'm running into currently is this error:</p>

<blockquote>
  <p>Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -9
    at java.lang.String.substring(String.java:1958)
    at jcutil.jcFormat.main(jcFormat.java:40)
  Java Result: 1</p>
</blockquote>

<p>If I test my code on the first ~10 lines of data.json it works just fine so I'm trying to figure out which line(s) are causing issues and as a new person to java my debugging skills aren't very good so any help figuring out why i'm getting this error would be greatly appreciated.</p>
