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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
   | import java.io.*;
public class Terminal{    
    static BufferedReader in =
	new BufferedReader(new InputStreamReader(System.in));
    public static String lireString() // Lire un String
	{
	    String tmp="";
	    char C='\0';
	    try {
		tmp = in.readLine();
	    }
	    catch (IOException e)
	    {
		exceptionHandler(e);
	    }
	    return tmp;
	} // fin de lireString()
    public static int lireInt()  // Lire un entier
	{
	    int x=0;
	    try {
		x=Integer.parseInt(lireString());
	    }
	    catch (NumberFormatException e) {
		exceptionHandler(e);
	    }	
	    return x ;
	}
    public static boolean lireBoolean()  // Lire un boolean
	{
	    boolean b = true;
	    try {
		b = Boolean.valueOf(lireString()).booleanValue();
	    }
	    catch (NumberFormatException e) {
		exceptionHandler(e);
	    }	
	    return b;
	}
    public  static double lireDouble()  // Lire un double
	{
	    double x=0.0;
	    try {
		x=Double.valueOf(lireString()).doubleValue();
	    }
	    catch (NumberFormatException e) {
		exceptionHandler(e);
	    }	
	    return x ;
	}
    public  static char lireChar()  // Lire un caractere
	{
	    String tmp=lireString();
	    if (tmp.length()==0)
		return '\n';
	    else 
	    {
		return tmp.charAt(0);
	    }
	}
    public static void ecrireString(String s){ // Afficher un String
	try{
	    System.out.print(s);
	} catch (Exception ex){
	    exceptionHandler(ex);
	}
    }
    public static void ecrireStringln(String s) // Afficher un String
	{
	    ecrireString(s);
	    sautDeLigne();
	} // fin de ecrireStringln()
    public static void ecrireInt(int i)  // Afficher un entier
	{
	    ecrireString(""+i);
	}
    public static void ecrireIntln(int i)  // Afficher un entier
	{
	    ecrireString(""+i);
	    sautDeLigne();
	}
    public static void ecrireBoolean(boolean b){
	ecrireString(""+b);
    }
    public static void ecrireBooleanln(boolean b){
	ecrireString(""+b);
	sautDeLigne();
    }
    public  static void ecrireDouble(double d)  // Afficher un double
	{
	    ecrireString(""+d);
	}
    public  static void ecrireDoubleln(double d)  // Afficher un double
	{
	    ecrireDouble(d);
	    sautDeLigne();
	}
    public  static void ecrireChar(char c)  // Afficher un caractere
	{
	    ecrireString(""+c);
	}  
    public  static void ecrireCharln(char c)  // Afficher un caractere
	{
	    ecrireChar(c);
	    sautDeLigne();
	}
    public static void sautDeLigne(){
	try{
	    System.out.println();
	}catch(Exception ex){
	    exceptionHandler(ex);
	}
    }
    protected static void exceptionHandler(Exception ex){
	TerminalException err = new TerminalException(ex);
	throw err;
    }
    public static void ecrireException(Throwable ex){
	ecrireString(ex.toString());
	ex.printStackTrace(System.err);
    }
}  
class TerminalException extends RuntimeException{
    Exception ex;
    TerminalException(Exception e){
	ex = e;
    }
} | 
Partager