<java> IOException cannot be resolved to a type

cs_domxaline Messages postés 327 Date d'inscription jeudi 21 août 2008 Statut Membre Dernière intervention 10 mai 2012 - 22 juin 2009 à 11:03
 Utilisateur anonyme - 22 juin 2009 à 20:42
Bonjour,

package sdz1;
public class Lire
{
// Cette fonction permet de saisir au clavier une variable de type String
public static String chaine()
{
String tmp = "";
char C='\0';
try
{
while ((C=(char) System.in.read()) !='\n')
{ if (C !'\r') tmp tmp+C;

}
}
catch (IOException e)
{
System.out.println("Erreur de frappe");
System.exit(0);
}
return tmp;
}

// Cette fonction permet de saisir au clavier une variable entière de type byte
public static byte entierByte()
{
byte x=0;
try
{
x = Byte.parseByte(chaine());
}
catch (NumberFormatException e)
{
System.out.println("Format numérique incorrect");
System.exit(0);
}
return x ;
}

// Cette fonction permet de saisir au clavier une variable entière de type Short
public static short entierShort()
{
short x=0;
try
{
x=Short.parseShort(chaine());
}
catch (NumberFormatException e)
{
System.out.println("Format numérique incorrect");
System.exit(0);
}
return x ;
}

// Cette fonction permet de saisir au clavier une variable entière de type int
public static int entierInt()
{
int x=0;
try
{
x=Integer.parseInt(chaine());
}
catch (NumberFormatException e)
{
System.out.println("Format numérique incorrect");
System.exit(0);
}
return x ;
}

// Cette fonction permet de saisir au clavier une variable entière de type long
public static long entierLong()
{
long x=0;
try
{
x=Integer.parseInt(chaine());
}
catch (NumberFormatException e)
{
System.out.println("Format numérique incorrect");
System.exit(0);
}
return x ;
}

// Cette fonction permet de saisir au clavier une variable réelle double
public static double reelDouble()
{
double x=0.0;
try
{
x=Double.valueOf(chaine()).doubleValue();
}
catch (NumberFormatException e)
{
System.out.println("Format numérique incorrect");
System.exit(0);
}
return x ;
}

// Cette fonction permet de saisir au clavier une variable réelle float
public static float reelFloat()
{
float x=0.0f;
try
{
x=Double.valueOf(chaine()).floatValue();
}
catch (NumberFormatException e)
{
System.out.println("Format numérique incorrect");
System.exit(0);
}
return x ;
}

// Cette fonction permet de saisir au clavier une variable de type char
public static char caractere()
{
String tmp=chaine();
if (tmp.length()==0)
{
return '\n';
}
else
{
return tmp.charAt(0);
}
}
}

j'ai essayé ce prg il m'envoie error message suivant
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
IOException cannot be resolved to a type

at sdz1.Lire.chaine(Lire.java:20)
at sdz1.Lire.entierByte(Lire.java:34)
at sdz1.sdz1.main(sdz1.java:9)

veuillez m'aider
A voir également:

3 réponses

cs_domxaline Messages postés 327 Date d'inscription jeudi 21 août 2008 Statut Membre Dernière intervention 10 mai 2012 2
22 juin 2009 à 11:11
merci beaucoup,
j'ai trouvé resolu
0