Voilà, je chercher à créer un tableau de String contenant les lignes d'un fichier texte. Seulement à l'exécution du programme l'erreur NullPointerException apparaît. Pourtant toutes les variables sont initialisées (enfin je pense .. )
Voila le code, merci de m'indiquer l'erreur.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public class RecupText {
	public static void main(String[] args){
 
		String fichier ="Liens.txt";	
                String[]tab = null ;	
 
		//lecture du fichier texte à 38 lignes
		try{
			InputStream ips=new FileInputStream(fichier);
			InputStreamReader ipsr=new InputStreamReader(ips);
			BufferedReader br=new BufferedReader(ipsr);
			String ligne = null;			
			while ((ligne=br.readLine())!=null){
				for (int i=1; i< 38; i++)
				{
					tab[i] = ligne;
					System.out.println(tab);
				}
 
			}
			br.close(); 
		}		
		catch (Exception e){
			System.out.println(e.toString());
		}
 
 
 
	}
}