OVH Cloud OVH Cloud

Problème d'exception sous Netbeans v4.1

1 réponse
Avatar
Joseph KHOURY
Bonjour,

J'ai un problème avec mon programme exécuté sous Netbeans version 4.1. le
programme est le suivant :
--------------------------------------------
import java.util.Scanner;
public class Create
{
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
System.out.println("Taper sur n'importe quelle touche pour
terminer");
String stop = s.nextLine();
}
}

au run sous netBeans j'ai l'exception suivante :

Taper sur n'importe quelle touche pour terminer
Exception in thread "main" java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Scanner.java:1471)
at Create.main(Create.java:8)

Pourquoi ? Sachant qu'en mode console le run marche

Merci de votre aide

1 réponse

Avatar
TestMan
Bonjour,

Essaye une variante :
http://elliottback.com/wp/archives/2005/09/06/using-scanner-to-stop-reading-input-on-a-blank-line/

A+

TM

Bonjour,

J'ai un problème avec mon programme exécuté sous Netbeans version 4.1. le
programme est le suivant :
--------------------------------------------
import java.util.Scanner;
public class Create
{
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
System.out.println("Taper sur n'importe quelle touche pour
terminer");
String stop = s.nextLine();
}
}

au run sous netBeans j'ai l'exception suivante :

Taper sur n'importe quelle touche pour terminer
Exception in thread "main" java.util.NoSuchElementException: No line found
at java.util.Scanner.nextLine(Scanner.java:1471)
at Create.main(Create.java:8)

Pourquoi ? Sachant qu'en mode console le run marche

Merci de votre aide