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édenteDernière révisionLes deux révisions suivantes | ||
informatique:java:tips [16/06/2011 01:56] – [Java Tips] cyrille | informatique:java:tips [16/01/2016 13:38] – [Read input from console] cyrille | ||
---|---|---|---|
Ligne 3: | Ligne 3: | ||
Plein de choses interressantes dans le livre " | Plein de choses interressantes dans le livre " | ||
- | http:// | + | http:// |
+ | |||
+ | [[http:// | ||
===== Swing ===== | ===== Swing ===== | ||
* [[http:// | * [[http:// | ||
* About [[/ | * About [[/ | ||
+ | * 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 ===== | ||
Ligne 60: | Ligne 136: | ||
class2.processDataFromInputStream(cbb.getInputStream()); | class2.processDataFromInputStream(cbb.getInputStream()); | ||
</ | </ | ||
+ | |||
+ | ===== Serial communication ===== | ||
+ | |||
+ | Communication série avec Java | ||
+ | |||
+ | * http:// | ||
+ | * http:// | ||
+ | |||
+ | |||
informatique/java/tips.txt · Dernière modification : 16/06/2023 10:02 de cyrille