bonjour a tous
voila j'ai un pgm en java qui lit un fichier .txt et mettre ces lignes dans un tableau,le fichier contient 6 lignes alors la table doit contenire 6 lignes mais il m'affiche que la taille du fichier est 15 et le tableau de sortie est null,voici le code:
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
31
32
33
34
35
36
37
38
39
40
41
42
 
import java.io.*;
 
public class  LireFichier{
 
	  static File fichier=new File("users.txt");;
	  static int i=0;	
 
     public static String []  lecture_fichier(String fichier) {
 
       int taille=fichier.length();
       System.out.println(taille);
       String[] tableau=new String[taille];
 
		try{
			InputStream ips=new FileInputStream(fichier); 
			InputStreamReader ipsr=new InputStreamReader(ips);
			BufferedReader br=new BufferedReader(ipsr);
			String  ligne;
 
			while ((ligne=br.readLine())!=null){
		    	tableau[i]=ligne;
		    	System.out.println(tableau[i]);
    	       	i++;	
    	    	}
	    	br.close();
	    	}		
		catch (Exception e){
			System.out.println(e.toString());
		    }
	  return tableau ;
 
	}
 
	public static void main (String[] args){
	 String	rep[]=lecture_fichier("utilisateur.txt");
	 	   	for(int j=0;j<rep.length;j++) { 
        	System.out.println(rep[i]);
            }
 
	 	}		
}
je ne sais pas ou est le pb ,un peut d'aide merci d'avance