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]);
}
}
} |