informatique:java:tips
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédente | Dernière révisionLes deux révisions suivantes | ||
informatique:java:tips [28/12/2015 01:05] – [Process Input Stream Reader] cyrille | informatique:java:tips [16/01/2016 13:38] – [Read input from console] cyrille | ||
---|---|---|---|
Ligne 14: | Ligne 14: | ||
* [[http:// | * [[http:// | ||
+ | |||
+ | ===== Read input from console ===== | ||
+ | |||
+ | Read console input using **java.io.Console** instance - // | ||
+ | <code java> | ||
+ | private static void usingConsoleReader() | ||
+ | { | ||
+ | Console | ||
+ | if (console != null) | ||
+ | { | ||
+ | | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Read console input using **BufferedReader** instance | ||
+ | <code java> | ||
+ | private static void usingBufferedReader() | ||
+ | { | ||
+ | BufferedReader bufferRead = new BufferedReader( new InputStreamReader( System.in ) ); | ||
+ | String inputString = bufferRead.readLine(); | ||
+ | System.out.println( inputString ); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | Read console input using **Scanner** instance | ||
+ | <code java> | ||
+ | private static void usingScanner() | ||
+ | { | ||
+ | Scanner scanIn = new Scanner( System.in ); | ||
+ | String inputString = scanIn.nextLine(); | ||
+ | scanIn.close(); | ||
+ | System.out.println(inputString); | ||
+ | } | ||
+ | </ | ||
===== Process Input Stream Reader ===== | ===== Process Input Stream Reader ===== |
informatique/java/tips.txt · Dernière modification : 16/06/2023 10:02 de cyrille