Scanner et ecriture fichier texte
Bonjour,
J'essaie d'écrire dans un fichier texte et j'utilise la méthode Scanner pour prendre ce que l'utilisateur va insérer au clavier mais ca ne joue pas !
Voici le code :
Code:
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
| import java.util.Scanner;
import java.io.FileWriter;
public class IpEcrireFichierTexte {
public static void main ( String args [])
{
char ip = '0';
Scanner scanner = new Scanner (System.in);
ip = scanner.nextLine();
FileWriter fw;
try
{
fw = new FileWriter("ip.txt");
fw.write(ip);
fw.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
} |
et voici l'erreur de Eclipse (il m'enquiquine :oops: avec le Scanner) :
Code:
1 2 3 4 5 6
| java.lang.Error: Unresolved compilation problems:
Scanner cannot be resolved to a type
Scanner cannot be resolved to a type
at IpEcrireFichierTexte.main(IpEcrireFichierTexte.java:11)
Exception in thread "main" |
Est-ce que qqun à une solution ou à déja eu ce problème ?