What is wrong with my code? Exception in thread "main" java.lang.NumberFormatException: For input string: "npcId"
<p>Exception in thread "main" java.lang.NumberFormatException: For input string: "npcId"
I get that when I try to run it.</p>

<p>What is wrong?
Pretty much what the class does is reads and packs the unPacked definitions of NPC's into a file, but it is not packing correctly. (See below for format I'm using)</p>

<p>The class:</p>

<pre><code>package com.rs.utils;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.HashMap;

import com.rs.game.npc.combat.NPCCombatDefinitions;

// Referenced classes of package com.rs.utils:
//            Logger

public final class NPCCombatDefinitionsL
{

    public static void init()
    {
        if((new File("data/npcs/packedCombatDefinitions.ncd")).exists())
            loadPackedNPCCombatDefinitions();
        else
            loadUnpackedNPCCombatDefinitions();
    }

    public static NPCCombatDefinitions getNPCCombatDefinitions(int npcId)
    {
        NPCCombatDefinitions def = (NPCCombatDefinitions)npcCombatDefinitions.get(Integer.valueOf(npcId));
        if(def == null)
            return DEFAULT_DEFINITION;
        else
            return def;
    }

    private static void loadUnpackedNPCCombatDefinitions()
    {
        int count = 0;
        Logger.log("NPCCombatDefinitionsL", "Packing npc combat definitions...");
        try
        {
            DataOutputStream out = new DataOutputStream(new FileOutputStream("data/npcs/packedCombatDefinitions.ncd"));
            BufferedReader in = new BufferedReader(new FileReader("data/npcs/unpackedCombatDefinitionsList.txt"));
            do
            {
                String line = in.readLine();
                count++;
                if(line == null)
                    break;
                if(!line.startsWith("//"))
                {
                    String splitedLine[] = line.split(" - ", 2);
                    if(splitedLine.length != 2)
                        throw new RuntimeException((new StringBuilder("Invalid NPC Combat Definitions line: ")).append(count).append(", ").append(line).toString());
                    int npcId = Integer.parseInt(splitedLine[0]);
                    String splitedLine2[] = splitedLine[1].split(" ", 12);
                    if(splitedLine2.length != 12)
                        throw new RuntimeException((new StringBuilder("Invalid NPC Combat Definitions line: ")).append(count).append(", ").append(line).toString());
                    int hitpoints = Integer.parseInt(splitedLine2[0]);
                    int attackAnim = Integer.parseInt(splitedLine2[1]);
                    int defenceAnim = Integer.parseInt(splitedLine2[2]);
                    int deathAnim = Integer.parseInt(splitedLine2[3]);
                    int attackDelay = Integer.parseInt(splitedLine2[4]);
                    int deathDelay = Integer.parseInt(splitedLine2[5]);
                    int respawnDelay = Integer.parseInt(splitedLine2[6]);
                    int maxHit = Integer.parseInt(splitedLine2[7]);
                    int attackStyle;
                    if(splitedLine2[8].equalsIgnoreCase("MELEE"))
                        attackStyle = 0;
                    else
                    if(splitedLine2[8].equalsIgnoreCase("RANGE"))
                        attackStyle = 1;
                    else
                    if(splitedLine2[8].equalsIgnoreCase("MAGE"))
                        attackStyle = 2;
                    else
                    if(splitedLine2[8].equalsIgnoreCase("SPECIAL"))
                        attackStyle = 3;
                    else
                    if(splitedLine2[8].equalsIgnoreCase("SPECIAL2"))
                        attackStyle = 4;
                    else
                        throw new RuntimeException((new StringBuilder("Invalid NPC Combat Definitions line: ")).append(line).toString());
                    int attackGfx = Integer.parseInt(splitedLine2[9]);
                    int attackProjectile = Integer.parseInt(splitedLine2[10]);
                    int agressivenessType;
                    if(splitedLine2[11].equalsIgnoreCase("PASSIVE"))
                        agressivenessType = 0;
                    else
                    if(splitedLine2[11].equalsIgnoreCase("AGRESSIVE"))
                        agressivenessType = 1;
                    else
                        throw new RuntimeException((new StringBuilder("Invalid NPC Combat Definitions line: ")).append(line).toString());
                    out.writeShort(npcId);
                    out.writeShort(hitpoints);
                    out.writeShort(attackAnim);
                    out.writeShort(defenceAnim);
                    out.writeShort(deathAnim);
                    out.writeByte(attackDelay);
                    out.writeByte(deathDelay);
                    out.writeInt(respawnDelay);
                    out.writeShort(maxHit);
                    out.writeByte(attackStyle);
                    out.writeShort(attackGfx);
                    out.writeShort(attackProjectile);
                    out.writeByte(agressivenessType);
                    npcCombatDefinitions.put(Integer.valueOf(npcId), new NPCCombatDefinitions(hitpoints, attackAnim, defenceAnim, deathAnim, attackDelay, deathDelay, respawnDelay, maxHit, attackStyle, attackGfx, attackProjectile, agressivenessType));
                }
            } while(true);
            in.close();
            out.close();
        }
        catch(FileNotFoundException e)
        {
            e.printStackTrace();
        }
        catch(IOException e)
        {
            e.printStackTrace();
        }
    }

    private static void loadPackedNPCCombatDefinitions()
    {
        try
        {
            RandomAccessFile in = new RandomAccessFile("data/npcs/packedCombatDefinitions.ncd", "r");
            FileChannel channel = in.getChannel();
            int npcId;
            int hitpoints;
            int attackAnim;
            int defenceAnim;
            int deathAnim;
            int attackDelay;
            int deathDelay;
            int respawnDelay;
            int maxHit;
            int attackStyle;
            int attackGfx;
            int attackProjectile;
            int agressivenessType;
            for(ByteBuffer buffer = channel.map(java.nio.channels.FileChannel.MapMode.READ_ONLY, 0L, channel.size()); buffer.hasRemaining(); npcCombatDefinitions.put(Integer.valueOf(npcId), new NPCCombatDefinitions(hitpoints, attackAnim, defenceAnim, deathAnim, attackDelay, deathDelay, respawnDelay, maxHit, attackStyle, attackGfx, attackProjectile, agressivenessType)))
            {
                npcId = buffer.getShort() &amp; 0xffff;
                hitpoints = buffer.getShort() &amp; 0xffff;
                attackAnim = buffer.getShort() &amp; 0xffff;
                defenceAnim = buffer.getShort() &amp; 0xffff;
                deathAnim = buffer.getShort() &amp; 0xffff;
                attackDelay = buffer.get() &amp; 0xff;
                deathDelay = buffer.get() &amp; 0xff;
                respawnDelay = buffer.getInt();
                maxHit = buffer.getShort() &amp; 0xffff;
                attackStyle = buffer.get() &amp; 0xff;
                attackGfx = buffer.getShort() &amp; 0xffff;
                attackProjectile = buffer.getShort() &amp; 0xffff;
                agressivenessType = buffer.get() &amp; 0xff;
            }

            channel.close();
            in.close();
        }
        catch(IOException e)
        {
            e.printStackTrace();
        }
    }

    private NPCCombatDefinitionsL()
    {
    }

    private static final HashMap&lt;Integer, NPCCombatDefinitions&gt; npcCombatDefinitions = new HashMap&lt;Integer, NPCCombatDefinitions&gt;();
    private static final NPCCombatDefinitions DEFAULT_DEFINITION = new NPCCombatDefinitions(1, -1, -1, -1, 5, 1, 1, 0, 0, -1, -1, 0);
    @SuppressWarnings("unused")
    private static final String PACKED_PATH = "data/npcs/packedCombatDefinitions.ncd";
}
</code></pre>

<p>The format in the text file:
<a href="http://pastebin.com/ngrECkuD" rel="nofollow">http://pastebin.com/ngrECkuD</a></p>
