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:pl.edu.amu.wmi.bank.Bank.java
public static void main(String[] args) throws InterruptedException, IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); ApplicationContext context = new ClassPathXmlApplicationContext("Context.xml"); SendPublicKeyService keySender = (SendPublicKeyService) context.getBean("sendPublicKeyToShopService"); keySender.sendPublicKey();//from w ww .ja v a 2 s.c om Accounts accounts = (Accounts) context.getBean("accounts"); System.out.println(accounts); while (true) { System.out.println("Wcisnij cokolwiek zeby ponownie wyslac klucz"); reader.readLine(); keySender.sendPublicKey(); } }
From source file:es.us.isa.ideas.utilities.HashPassword.java
public static void main(String[] args) throws IOException { Md5PasswordEncoder encoder;// w w w . jav a 2 s. c om InputStreamReader stream; BufferedReader reader; String line, hash; encoder = new Md5PasswordEncoder(); stream = new InputStreamReader(System.in); reader = new BufferedReader(stream); System.out.println("Enter passwords to be hashed or <ENTER> to quit"); line = reader.readLine(); while (!line.isEmpty()) { hash = encoder.encodePassword(line, null); System.out.println(hash); line = reader.readLine(); } }
From source file:comparetopics.CompareTwoGroupTopics.java
public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("please input the path for File1: "); String filepath1 = sc.nextLine(); System.out.println("please input the path for File2: "); String filepath2 = sc.nextLine(); try {/* w ww . j a v a 2 s . c o m*/ File file1 = new File(filepath1); File file2 = new File(filepath2); System.out.println("File1: " + filepath1); System.out.println("File2: " + filepath2); if (!file1.exists()) { System.out.println("File1 isn't exist"); } else if (!file2.exists()) { System.out.println("File2 isn't exist"); } else { try (InputStream in1 = new FileInputStream(file1.getPath()); BufferedReader reader1 = new BufferedReader(new InputStreamReader(in1))) { String line1 = null; int lineNr1 = -1; while ((line1 = reader1.readLine()) != null) { ++lineNr1; int lineNr2 = -1; String line2 = null; try (InputStream in2 = new FileInputStream(file2.getPath()); BufferedReader reader2 = new BufferedReader(new InputStreamReader(in2))) { while ((line2 = reader2.readLine()) != null) { ++lineNr2; compareTwoGroups(line1, line2, lineNr1, lineNr2); } } System.out.println(); } } } } catch (IOException ex) { Logger.getLogger(CompareTopics.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:mx.com.pixup.portal.demo.DemoDisqueraDelete.java
public static void main(String[] args) { System.out.println("BIENVENIDO A PIXUP"); System.out.println("Mantenimiento catlogo disquera"); System.out.println("Inserte el nombre de la disquera a eliminar: "); InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); Connection connection = null; Statement statement = null;/*from w w w .ja va 2 s . c om*/ try { String nombreDisquera = br.readLine(); BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUsername("root"); dataSource.setPassword("admin"); dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/pixup"); connection = dataSource.getConnection(); statement = connection.createStatement(); String sql = "delete from disquera where nombre = '" + nombreDisquera + "'"; statement.execute(sql); System.out.println("Disquera: " + nombreDisquera + " eliminada con xito"); } catch (Exception e) { System.out.println("Error en el sistema, intente ms tarde!!"); } finally { if (statement != null) { try { statement.close(); } catch (Exception e) { } } if (connection != null) { try { connection.close(); } catch (Exception e) { } } } }
From source file:irckafka.ChatApp.java
public static void main(String[] args) { groupId = RandomStringUtils.random(8, true, true); boolean isOnline = true; Scanner in = new Scanner(System.in); while (isOnline) { String[] input = in.nextLine().split(" "); String command = input[0].toLowerCase(); switch (command) { case "/nick": if (input.length >= 2) { nickname = input[1];//w ww . j av a 2 s . c o m System.out.println("your nickname is " + nickname); } else { System.out.println("write nick name please!"); } break; case "/join": if (input.length >= 2) { KafkaConsumer consume = new KafkaConsumer(groupId, input[1]); consume.start(); channelGroup.put(input[1], consume); } else { System.out.println("write channel name please!"); } break; case "/leave": if (input.length >= 2) { if (channelGroup.containsKey(input[1])) { KafkaConsumer consume = channelGroup.get(input[1]); consume.shutdown(); channelGroup.remove(input[1]); System.out.println("your leave channel " + input[1]); } else { System.out.println("wrong channel name!!"); } } else { System.out.println("write channel name please!"); } break; case "/exit": System.out.println("bye"); System.exit(0); break; default: //broadcast if (command.contains("@")) { String channelname = command.substring(1); KafkaProducer produce = new KafkaProducer(); if (channelGroup.containsKey(channelname)) { String message = ""; for (int i = 1; i < input.length; i++) { message += input[i] + " "; } produce.sendMessage(channelname, message, nickname); } produce.closeConnection(); } else { String message = ""; for (int i = 0; i < input.length; i++) { message += input[i] + " "; } KafkaProducer produce = new KafkaProducer(); for (String cList : channelGroup.keySet()) { produce.sendMessage(cList, message, nickname); } produce.closeConnection(); } } } }
From source file:mx.com.pixup.portal.demo.DemoDisqueraUpdate.java
public static void main(String[] args) { System.out.println("BIENVENIDO A PIXUP"); System.out.println("Mantenimiento catlogo disquera"); System.out.println("Actualizacin de Disquera"); InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); Connection connection = null; Statement statement = null;/* w ww . ja v a 2s. co m*/ ResultSet resultSet = null; try { BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUsername("root"); dataSource.setPassword("admin"); dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/pixup"); connection = dataSource.getConnection(); statement = connection.createStatement(); String sql = "select id, nombre from disquera order by nombre"; resultSet = statement.executeQuery(sql); System.out.println("Id Disquera: \t Nombre Disquera"); while (resultSet.next()) { System.out.println(resultSet.getInt("id") + " \t " + resultSet.getString("nombre")); } System.out.println("Proporcione el id de la disquera a actualizar: "); String idDisquera = br.readLine(); System.out.println("Proporcione el nuevo nombre de la disquera: "); String nombreDisquera = br.readLine(); sql = "update disquera set nombre = '" + nombreDisquera + "' where id = " + idDisquera; statement.execute(sql); System.out.println("Disqueras Actualizadas:"); sql = "select id, nombre from disquera order by nombre desc"; resultSet = statement.executeQuery(sql); System.out.println("Id Disquera: \t Nombre Disquera"); while (resultSet.next()) { System.out.println(resultSet.getInt("id") + " \t " + resultSet.getString("nombre")); } } catch (Exception e) { System.out.println("Error en el sistema, intente ms tarde!!"); } finally { if (resultSet != null) { try { resultSet.close(); } catch (Exception e) { } } if (statement != null) { try { statement.close(); } catch (Exception e) { } } if (connection != null) { try { connection.close(); } catch (Exception e) { } } } }
From source file:math2605.gn_qua.java
/** * @param args the command line arguments *///from w w w .j av a 2 s .c o m public static void main(String[] args) { //get file name System.out.println("Please enter a file name:"); Scanner scanner = new Scanner(System.in); String fileName = scanner.nextLine(); List<String[]> pairs = new ArrayList<>(); //get coordinate pairs and add to arraylist try { BufferedReader br = new BufferedReader(new FileReader(fileName)); String line; while ((line = br.readLine()) != null) { String[] pair = line.split(","); pairs.add(pair); } br.close(); } catch (Exception e) { System.out.println(e.getMessage()); } System.out.println("Please enter the value of a:"); double a = scanner.nextInt(); System.out.println("Please enter the value of b:"); double b = scanner.nextInt(); System.out.println("Please enter the value of c:"); double c = scanner.nextInt(); //init B, vector with 3 coordinates RealMatrix B = new Array2DRowRealMatrix(3, 1); B.setEntry(0, 0, a); B.setEntry(1, 0, b); B.setEntry(2, 0, c); System.out.println("Please enter the number of iteration for the Gauss-newton:"); //init N, number of iterations int N = scanner.nextInt(); //init r, vector of residuals RealMatrix r = new Array2DRowRealMatrix(pairs.size(), 1); setR(pairs, a, b, c, r); //init J, Jacobian of r RealMatrix J = new Array2DRowRealMatrix(pairs.size(), 3); setJ(pairs, a, b, c, r, J); System.out.println("J"); System.out.println(J); System.out.println("r"); System.out.println(r); RealMatrix sub = findQR(J, r); for (int i = N; i > 0; i--) { B = B.subtract(sub); double B0 = B.getEntry(0, 0); double B1 = B.getEntry(1, 0); double B2 = B.getEntry(2, 0); //CHANGE ABC TO USE B0, B1, B2 setR(pairs, B0, B1, B2, r); setJ(pairs, B0, B1, B2, r, J); } System.out.println("B"); System.out.println(B.toString()); }
From source file:javaapplicationclientrest.JavaApplicationClientRest.java
/** * @param args the command line arguments *//*www .j a v a2s . c o m*/ public static void main(String[] args) { Scanner input = new Scanner(System.in); ControllerCliente controller = new ControllerCliente(); while (true) { controller.getMenu(); int op = 0; try { op = Integer.parseInt(input.nextLine()); } catch (Exception e) { } //input.nextLine(); switch (op) { case 1: controller.listarNoticias(); break; case 2: System.out.println("Informe o titulo: "); String titulo = input.nextLine(); if (titulo.trim().equals("")) { System.out.println("Ttulo invlido"); break; } System.out.println("Informe o autor: "); String autor = input.nextLine(); if (autor.trim().equals("")) { System.out.println("Autor invlido"); break; } System.out.println("Informe o Conteudo: "); String conteudo = input.nextLine(); if (conteudo.trim().equals("")) { System.out.println("Conteudo invlido"); break; } //System.out.println(id); controller.cadastrarNoticia(titulo, autor, conteudo); break; case 3: try { System.out.println("Informe o id da notcia a ser removida: "); String idN = input.nextLine(); Integer.parseInt(idN); controller.removerNoticia(idN); } catch (Exception e) { System.out.println("Numero invlido"); } break; case 4: try { System.out.println("Informe o Id da notcia desejada:"); String idN = input.nextLine(); Integer.parseInt(idN); controller.getNoticia(idN); } catch (Exception e) { System.out.println("Id invlido"); break; } break; case 5: try { System.out.println("Informe o Id da notcia para ser atualizada:"); String idA = input.nextLine(); Integer.parseInt(idA); System.out.println("Informe o novo titulo: "); String tituloN = input.nextLine(); controller.atualizarNoticia(idA, tituloN); } catch (Exception e) { System.out.println("Id invlido"); } break; default: System.out.println("Opo invlida. Escolha uma opo novamente"); break; } // End switch } // End while }
From source file:com.mycompany.test.Jaroop.java
/** * This is the main program which will receive the request, calls required methods * and processes the response.//from ww w . j av a 2 s . c om * @param args * @throws IOException */ public static void main(String[] args) throws IOException { Scanner scannedInput = new Scanner(System.in); String in = ""; if (args.length == 0) { System.out.println("Enter the query"); in = scannedInput.nextLine(); } else { in = args[0]; } in = in.toLowerCase().replaceAll("\\s+", "_"); int httpStatus = checkInvalidInput(in); if (httpStatus == 0) { System.out.print("Not found"); System.exit(0); } String url = "https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles=" + in; HttpURLConnection connection = getConnection(url); BufferedReader input = new BufferedReader(new InputStreamReader(connection.getInputStream())); String request = ""; StringBuilder response = new StringBuilder(); while ((request = input.readLine()) != null) { //only appending what ever is required for JSON parsing and ignoring the rest response.append("{"); //appending the key "extract" to the string so that the JSON parser can parse it's value, //also we don't need last 3 paranthesis in the response, excluding them as well. response.append(request.substring(request.indexOf("\"extract"), request.length() - 3)); } parseJSON(response.toString()); }
From source file:animalclient.AnimalClient.java
/** * @param args the command line arguments *//*from w w w . j a va 2s. c om*/ public static void main(String[] arg) throws IOException, MalformedURLException, ParseException { // TODO code application logic here InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String username; String password; System.out.println("Username:"); username = br.readLine(); System.out.println("Password:"); password = br.readLine(); AnimalJerseyClient client = new AnimalJerseyClient(username, password); System.out.println(""); System.out.println( "Willkommen bei ihrer Tierhandlung fr exotische Tiere. Geben sie help ein fr weitere Informationen"); String auswahl = br.readLine(); if (auswahl.equals("help")) { System.out.println("Sie haben folgende Auswahlmglichkeiten:"); System.out.println("1. Listen sie alle verfgbaren Tiere auf."); System.out.println("2. Kaufen sie ein Tier."); System.out.println("3. Suchen sie nach einem Tier."); System.out.println("4. Whrung ndern."); auswahl = br.readLine(); makeDecision(client, auswahl); } else { makeDecision(client, auswahl); } System.out.print("End"); }