List of usage examples for java.lang System in
InputStream in
To view the source code for java.lang System in.
Click Source Link
From source file:Main.java
public static void main(String[] args) throws Exception { DatagramSocket udpSocket = new DatagramSocket(); String msg = null;// www. j a v a 2 s . c o m BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Please enter a message (Bye to quit):"); while ((msg = br.readLine()) != null) { if (msg.equalsIgnoreCase("bye")) { break; } DatagramPacket packet = Main.getPacket(msg); udpSocket.send(packet); udpSocket.receive(packet); displayPacketDetails(packet); System.out.print("Please enter a message (Bye to quit):"); } udpSocket.close(); }
From source file:ReadZip.java
public static void main(String args[]) { try {// w ww . j a va 2 s . c om ZipFile zf = new ZipFile("ReadZip.zip"); Enumeration entries = zf.entries(); BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); while (entries.hasMoreElements()) { ZipEntry ze = (ZipEntry) entries.nextElement(); System.out.println("Read " + ze.getName() + "?"); String inputLine = input.readLine(); if (inputLine.equalsIgnoreCase("yes")) { long size = ze.getSize(); if (size > 0) { System.out.println("Length is " + size); BufferedReader br = new BufferedReader(new InputStreamReader(zf.getInputStream(ze))); String line; while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); } } } } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String args[]) throws java.io.IOException { char choice;//w ww .j av a2s. c om do { System.out.println("Help on:"); System.out.println(" 1. A"); System.out.println(" 2. B"); System.out.println(" 3. C"); System.out.println(" 4. D"); System.out.println(" 5. E"); System.out.println("Choose one:"); choice = (char) System.in.read(); } while (choice < '1' || choice > '5'); System.out.println("\n"); switch (choice) { case '1': System.out.println("A"); break; case '2': System.out.println("B"); break; case '3': System.out.println("C"); break; case '4': System.out.println("D"); break; case '5': System.out.println("E"); break; } }
From source file:DateFormatFile.java
public static void main(String[] args) throws IOException { DateFormatFile df = new DateFormatFile(); BufferedReader is = new BufferedReader(new InputStreamReader(System.in)); String line;//w w w . j a va 2 s . com while ((line = is.readLine()) != null) { df.process(line); } }
From source file:MainClass.java
public static void main(String[] args) throws Exception { String hostname = "localhost"; Socket theSocket = new Socket(hostname, 7); BufferedReader networkIn = new BufferedReader(new InputStreamReader(theSocket.getInputStream())); BufferedReader userIn = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(theSocket.getOutputStream()); System.out.println("Connected to echo server"); while (true) { String theLine = userIn.readLine(); if (theLine.equals(".")) break; out.println(theLine);//ww w . ja va 2 s . c om out.flush(); System.out.println(networkIn.readLine()); } networkIn.close(); out.close(); }
From source file:InputOutputDemoStandardInputOutput.java
public static void main(String[] a) throws Exception { //Write characters to standard output and standard error: System.out.println("std output"); System.err.println("std error"); //Read characters from standard input (the keyboard): System.out.print("Type some characters and press Enter: "); BufferedReader bisr = new BufferedReader(new InputStreamReader(System.in)); String response = bisr.readLine(); System.out.println("You typed: '" + response + "'"); //Read a byte from standard input (the keyboard): System.out.print("Type one character and press Enter: "); byte b = (byte) System.in.read(); System.out.println("First byte of your input is: " + b); }
From source file:MainClass.java
public static void main(String[] args) throws Exception { SSLSocketFactory sf = (SSLSocketFactory) SSLSocketFactory.getDefault(); Socket s = sf.createSocket(HOST, PORT); OutputStream out = s.getOutputStream(); out.write("\nConnection established.\n\n".getBytes()); out.flush();/*from ww w . j av a2s . c om*/ int theCharacter = 0; theCharacter = System.in.read(); while (theCharacter != '~') // The '~' is an escape character to exit { out.write(theCharacter); out.flush(); theCharacter = System.in.read(); } out.close(); s.close(); }
From source file:com.skynetcomputing.skynettools.Main.java
/** * @param args the command line arguments *///from w ww . ja va 2s . com public static void main(String[] args) throws IOException { Scanner s = new Scanner(System.in); boolean isRunning = true; while (isRunning) { System.out.println("Enter file path for MD5 hash. Leave empty to quit"); String input = s.nextLine(); isRunning = !input.isEmpty(); if (isRunning) { File inputFile = new File(input); if (inputFile.length() > 0) { try (FileInputStream fis = new FileInputStream(inputFile)) { String md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis); System.out.println("MD5: " + md5); } } } } }
From source file:Matrix_Operations.java
public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); //Allow user to enter number of columns int rows = getRowsNumberFromUser(); int columns = getColumnNumberFromUser(); double matrixA[][] = new double[rows][columns]; //Enter values for matrix System.out.println("Enter values for each position in the matrix below. "); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { matrixA[i][j] = keyboard.nextDouble(); }/*from ww w . j a v a2 s. c om*/ System.out.println(""); } showMatrix(matrixA); System.out.println(""); RealMatrix A = MatrixUtils.createRealMatrix(matrixA); LUDecomposition lu = new LUDecomposition(A); showMatrix(matrixA); System.out.println(lu.getDeterminant()); }
From source file:andy.zhang.dubbo.app.Main.java
public static void main(String[] args) throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "applicationProvider.xml" }); context.start();//from ww w. j a v a2 s . c om System.out.println("?"); System.in.read(); }