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édenteProchaine révision | Révision précédente | ||
informatique:java:tips [06/03/2013 17:43] – [Serial communication] cyrille | informatique:java:tips [16/06/2023 10:02] (Version actuelle) – [Swing] cyrille | ||
---|---|---|---|
Ligne 10: | Ligne 10: | ||
* [[http:// | * [[http:// | ||
* About [[/ | * About [[/ | ||
- | * Plein d' | + | * Plein d' |
===== CVS Format ===== | ===== CVS Format ===== | ||
* [[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 ===== | ||
+ | |||
+ | <code java> | ||
+ | import java.io.BufferedReader; | ||
+ | import java.io.IOException; | ||
+ | import java.io.InputStream; | ||
+ | import java.io.InputStreamReader; | ||
+ | import java.net.InetAddress; | ||
+ | import java.net.UnknownHostException; | ||
+ | import java.io.*; | ||
+ | |||
+ | public class Traceroute { | ||
+ | | ||
+ | Runtime t = Runtime.getRuntime(); | ||
+ | try { | ||
+ | | ||
+ | // | ||
+ | | ||
+ | | ||
+ | | ||
+ | int m =0; | ||
+ | | ||
+ | String content = re.readLine(); | ||
+ | System.out.println(content); | ||
+ | if(content == null){ | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | | ||
+ | } catch (IOException e) { | ||
+ | e.printStackTrace(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
===== Convert a Java OutputStream to an InputStream ===== | ===== Convert a Java OutputStream to an InputStream ===== |
informatique/java/tips.1362588224.txt.gz · Dernière modification : 06/03/2013 17:43 (modification externe)