Lecture dans un fichier(java)
Bonjour,
j'ai créé un programme où j'ai mis l'écriture d'un fichier en java et la lecture,j'ai un problème de lecture si quelqu'un peut m'aider ça serait sympa voilà mon programme:
import java.io.*;
public class Profil{
static String motDePasse;
static String NomUtilisateur;
public void Profil(){
motDePasse=" ";
NomUtilisateur=" ";
}
static BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args)throws IOException{
/*public static void fichierWriter()throws IOException{*/
try {
PrintWriter fil=new PrintWriter(new FileWriter("profil.x"));
System.out.println("Entrez un nom d'utilisateur");
Profil.NomUtilisateur=buf.readLine();
fil.write(NomUtilisateur);
System.out.println("Entrez un mot de passse");
Profil.motDePasse=buf.readLine();
fil.write(motDePasse);
fil.close();
FileReader fluxread=new FileReader("profil.x");
BufferedReader in=new BufferedReader(fluxread);
System.out.println("Voilà votre nom d'utilisateur et votre mot de passe");
try{
in.readLine();}
catch(IOException err){
throw new IOException(err.getMessage());}
in.close();
}catch(IOException err){
throw new IOException(err.getMessage());
}
}
}
j'ai créé un programme où j'ai mis l'écriture d'un fichier en java et la lecture,j'ai un problème de lecture si quelqu'un peut m'aider ça serait sympa voilà mon programme:
import java.io.*;
public class Profil{
static String motDePasse;
static String NomUtilisateur;
public void Profil(){
motDePasse=" ";
NomUtilisateur=" ";
}
static BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args)throws IOException{
/*public static void fichierWriter()throws IOException{*/
try {
PrintWriter fil=new PrintWriter(new FileWriter("profil.x"));
System.out.println("Entrez un nom d'utilisateur");
Profil.NomUtilisateur=buf.readLine();
fil.write(NomUtilisateur);
System.out.println("Entrez un mot de passse");
Profil.motDePasse=buf.readLine();
fil.write(motDePasse);
fil.close();
FileReader fluxread=new FileReader("profil.x");
BufferedReader in=new BufferedReader(fluxread);
System.out.println("Voilà votre nom d'utilisateur et votre mot de passe");
try{
in.readLine();}
catch(IOException err){
throw new IOException(err.getMessage());}
in.close();
}catch(IOException err){
throw new IOException(err.getMessage());
}
}
}
Configuration: Windows XP Firefox 0.9.3