How to fix java.lang.ArrayIndexOutOfBoundsException: 1

Discussion in 'Plugin Development' started by gamemakertim, Nov 14, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    gamemakertim

    Can anybody help me why i get the error 'java.lang.ArrayIndexOutOfBoundsException: 1'

    PHP:
     public String Input(String bestandsnaamint rijnummer){
    String input "";
    File f = new File("plugins" File.separator plugin.Naam File.separator bestandsnaam);
    StringBuffer contents = new StringBuffer();
    BufferedReader reader null;
    try{
    reader = new BufferedReader(new FileReader(f));
    String text null;
    int Rij 0;
    while ((
    text reader.readLine()) != null) {
    if(
    Rij == rijnummer){
    contents.append(text).append(System.getProperty("line.separator"));
    input contents.toString();
    }
    Rij Rij 1;
    }
    reader.close();
    if(!
    f.exists()){
    plugin.Console("The Language pack isn't found!");
    plugin.Console("The plugin has been disabeld!");
    plugin.getPluginLoader().disablePlugin(plugin);
    }
    String[] In input.split(": ");
    input In[1].toString();
    }
    catch(
    Exception e){plugin.DebugConsole(ChatColor.RED "Error: " e);}
    return 
    input;
    }
    The error is while the plugin is onEnable, en the row is the row of Return Input
     
  2. Offline

    Timr

    input = ""; input = contents.toString();

    If you try and split that, you'll get a String[] with no KVPs. That's why you get an exception.

    I would suggest checking that the size of the split string is >= (greater than or equal to) 2. If yes, proceed
     
Thread Status:
Not open for further replies.

Share This Page