je fait ce code mais il ma affiche des errerus svp aide moi à le corriger il y a un probleme d exeption
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication2;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.lang.IndexOutOfBoundsException;
/**catch (ArrayIndexOutOfBoundsException _)
*
* @author marwa
*/
public class heuristique1 {
// lire un document
public static ArrayList<String> lire_doc(String lex){
ArrayList<String> wordList =new ArrayList<String>();
try{
InputStream ips = new FileInputStream (lex);
InputStreamReader ipsr = new InputStreamReader (ips);
BufferedReader br = new BufferedReader(ipsr);
StreamTokenizer st = new StreamTokenizer(br);
int token;
while((token=st.nextToken())!=StreamTokenizer.TT_EOF){
if(token==StreamTokenizer.TT_WORD){
wordList.add(st.sval);
}
}
}catch(Exception e){
System.out.println(e.getMessage());
}
return wordList;
}
//lire un fichier line par line ..
public static void affiche(String fichier) throws IOException {
String filePath = "C:\\"+fichier +".txt";
ArrayList <String> m1 = new ArrayList <String>();
ArrayList<Integer> m2= new ArrayList<Integer>();
ArrayList<Integer>indice = new ArrayList<Integer>();
try{
// Création du flux bufférisé sur un FileReader, immédiatement suivi par un
// try/finally, ce qui permet de ne fermer le flux QUE s'il le reader
// est correctement instancié (évite les NullPointerException)
BufferedReader buff = new BufferedReader(new FileReader(filePath));
try {
// svp je veux à chaque fois qu 'il lire la ligne et le couper nombre par nombre et le met dans m1 et le deusieme dans m2
String line;
// Lecture du fichier ligne par ligne. Cette boucle se termine
// quand la méthode retourne la valeur null.
while ((line = buff.readLine()) != null) {
//System.out.println(line);win declaration mta3 m1?
m1=lire_doc(line);
// <editor-fold defaultstate="collapsed" desc="comment">
/*indice [0]=1;
for (int i=1;i<=m1.size;i++){
int j =indice[i-1];
indice[i] =indice[i-1]+(2*m1[j])+1;
}*/
for (int i = 1; i <= indice.size(); i++){
m2.add(Integer.parseInt(m1.get(i)));
}
indice.add(1);
for (int i = 1; i <= indice.size(); i++) {
int j = indice.get(i - 1);
int l = indice.get(i - 1) + (2 * m2.get(j))+ 1;// </editor-fold>
indice.add(i, l );
//indice[i] =indice[i-1]+(2*tab[j])+1;
}
//afficher les tableau
for (int h = 0;h<m2.size();h++){
System.out.println(m2.get(h));}
for (int k = 0;k<indice.size();k++){
System.out.println(indice.get(k));}
}
} finally {
// dans tous les cas, on ferme nos flux
buff.close();
}
} catch (IOException ioe) {
// erreur de fermeture des flux
System.out.println("Erreur --" + ioe.toString());
}}
public static void main(String[] arg) throws IOException{
affiche("marwa");
}}
le message de l execution est
5 1 2 6 1 3 1 1 1 2 2 2 6 4 6 3 6 5 2 6 1 1 (Le fichier spécifié est introuvable)
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at javaapplication2.heuristique1.affiche(heuristique1.java:82)
at javaapplication2.heuristique1.main(heuristique1.java:106)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
le fichier est sous c:
5 1 2 6 1 3 1 1 1 2 2 2 6 4 6 3 6 5 2 6 1 1
5 1 2 6 2 3 4 6 2 3 6 5 2 6 1 1 3 3 4 2 6 6 6 2 1 1 5 5
5 3 6 5 2 6 1 1 1 2 6 1 3 1 3 5 3 3 5 2 1 2 3 4 6 2
6 3 5 3 3 5 2 1 3 6 5 2 6 1 1 1 2 6 2 1 5 3 4 2 2 6 4 6 3 3 4 2 6 6 6
6 2 3 4 6 2 1 1 2 3 3 4 2 6 6 6 1 2 6 3 6 5 2 6 1 1 2 1 3 4 2
5 1 6 1 2 1 3 4 2 3 3 4 2 6 6 6 3 2 6 5 1 1 6 1 3 1
5 2 3 4 6 2 3 3 4 2 6 6 6 3 6 5 2 6 1 1 1 2 6 2 2 6 4 6
6 1 6 1 2 1 1 5 5 3 6 6 3 6 4 3 1 1 2 3 3 4 2 6 6 6 2 2 6 4 6
6 2 3 4 6 2 3 3 4 2 6 6 6 3 5 3 3 5 2 1 1 6 1 2 2 6 4 6 2 1 3 4 2

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1